npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pyro4-node

v2.4.0

Published

Client ("Proxy") and server ("Daemon") for interacting with Pyro4 objects.

Downloads

3

Readme

Pyro4 client (Proxy) and server (Daemon) for node.js v2.4.0

Build Status

Connect to Pyro4 objects using node.js, using the Pyro4 JSON serializer.

Usage

Client-side

// basic-proxy.js

const { Proxy } = require("./../index.js")

var main = async ()=>{
    var p = new Proxy("Pyro:BasicServer@localhost:50001")
    await p.init()
    console.log(await p.square([2]))
    console.log(await p.name.get())
    await p.end()
}

main()

In order to avoid having to call Proxy.init and Proxy.end, use the the Proxy.with function:

// with-proxy.js
const { Proxy } = require("./../index.js")

var main = async ()=>{
    var uri = "Pyro:BasicServer@localhost:50001"
    await Proxy.with(uri, async (proxy)=>{
        console.log(await proxy.square([2]))
        console.log(await proxy.name.get())
        console.log(await proxy.echo(["hey there"]))
    })
}

main()

As of version 2.3.0, you can make batched calls. This is simply a matter of making a list of calls (really just Promises), and then awaiting Promise.all:

// proxy-batched.js
const { Proxy } = require("./../index.js")

var main = async ()=>{
    var uri = "Pyro:TestServer@localhost:50001"
    await Proxy.with(uri, async (proxy)=>{
        var calls = []
        for (let i=1; i<=100; i++){
            calls.push(proxy.square([i]))
        }
        var resp = await Promise.all(calls)
        console.log(resp)
    })
}

main()

Server-side

Launching name server:

me@local:~$ pyro4-node-ns

With nameserver running in background, we can register an object with a Daemon, and then with the NameServer:


// basic-server.js
const { locateNS, expose, Daemon, NameServerDaemon } = require("./../index.js")

class BasicServer{
    constructor(){
        this._name = "BasicServer"
    }

    get name(){
        return this._name
    }

    set name(value){
        this._name = value
    }

    square(x){
        return x**2
    }

    echo(val){
        return val
    }

    ping(){}
}

expose(BasicServer.prototype.echo)
expose(BasicServer.prototype.square)
expose(BasicServer, "name")

var main = async ()=>{
    var server = new BasicServer()
    // We're going to register our server object on port 50002
    var daemon = new Daemon({host: "localhost", port: 50002})
    var uri = daemon.register(server)
    // with name server running, assuming it's running on port 9090
    await locateNS(async (ns)=>{
        var resp = await ns.register(["BasicServer", uri.str])
    })
    console.log(`Server's URI is ${uri.str}`)
    await daemon.init()
}

main()

Acknowledgements

Pyro4 is developed by Irmen de Jong. See here for Pyro4's license.