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

jigsaw-net

v0.0.2-dev13

Published

jigsaw-net is a set of components make jigsaws intercommunicating

Downloads

37

Readme

Introduction

jigsaw-net is an Extension of Jigsaw-RPC, it build a Logical Network for jigsaws, and making networks to connect to each others.

Usage

① Build an Logical Network by "NetHelper" for jigsaws

② Create an Network Interface for this Logical Network

③ Make the Interface created connecting to another Interface

④ Then all of jigsaws in these two Network can communicate to each other!


Network A Infomation:

Jigsaw Net Name: NetA

Host IP: 192.168.2.100

Network A : net-a.js

let helperA = new NetHelper("NetA");
helperA.getNewInterface("intf","jigsaw://192.168.2.100/","NetB","intf");

/*
create a Interface of NetworkA named intf, and make this Interface connect to NetworkB's intf
*/

Network A : app.js


let ANode = RPC.GetJigsaw({name:"ANode",registry:"jigsaw://127.0.0.1:1001/"})
ANode.port("get",async()=>{
    console.log("recv a far away invoking request");
    return "cool!  you called across a Net!";
});

Network B Infomation:

Jigsaw Net Name: NetB

Host IP: 192.168.3.100

Network B : net-b.js

let helperB = new NetHelper("NetB");
helperB.getNewInterface("intf");

/*
create a Interface of NetworkB named intf, but don't connect to other interface.
*/

Network B : app.js

const { RPC } = require("jigsaw-rpc");
RPC.pre(Middleware.create("jigsaw://127.0.0.1/").handle());


let BNode = RPC.GetJigsaw({name:"BNode",registry:"jigsaw://127.0.0.1/"});

BNode.send("NetA/ANode:get").then(console.log);

/* will print 'cool! you called across a Net' */

You can use CLI Tool 'jgnet' to inspect this interface

run 'jgnet listintfs' in NetA will get this:

NetA

<intf> <- [ NetB:intf ]

run 'jgnet listintfs' in NetB will get this:

NetB

<intf> -> [ NetA:intf ]

CLI Tool

if you run this command to install jigsaw-net globally, you will get the CLI Tool : jgnet

npm install jigsaw-net -g

run this to show help:

jgnet

  jigsaw-net is a set of components make jigsaws intercommunicating

  Usage:
      jgnet <start|stop|init|listintf|listnodes|list|ls> <args>

      jgnet init
      jgnet list
      jgnet listnodes jigsaw://127.0.0.1/
      jgnet listintfs jigsaw://127.0.0.1/
      jgnet start netconfig.js
      jgnet stop MyNetA

the CLI Tool help you to build a Jigsaw Logical Network easily.


① jgnet init:

This command will generate a file named netconfig.js . the config file contains:


module.exports = {
    "netname":"MyNetA",
    "routes":[
//      ["MyNetB","intf2"]
    ],
    "interfaces":[
        {
            "name":"intf1",
            "entry":"example.com",
        },
        {
            "name":"intf2",
            "entry":"127.0.0.1",
//          "to_registry":"jigsaw://example.com/",
//          "to_netname":"MyNetB",
//          "to_interface":"intf1"
        }
    ],
    "enable_registry":true
}

start the network described by the config file by running this

(Must install PM2 firstly):

jgnet start netconfig.js 

②jgnet list

this command will print all Network Helper running on this computer.

③jgnet listnodes

this command will show all nodes of Jigsaw Registry Server you specified.

|-- jigsaw-net
|---- config
|---- helper
|-- intf1
|-- intf2

④jgnet listintfs

this command will show all interfaces of specified Jigsaw Logical Network

MyNetA

<intf1> ?  [        ]
<intf2> -> [ MyNetB : intf1 ]