Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fingerprint-container-node-sdk2

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fingerprint-container-node-sdk2

fingerprint container's sdk

  • 0.0.5
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by700%
Maintainers
1
Weekly downloads
 
Created
Source

FPC NODE SDK

Run Unit Test

npm install && npm test

Server API

    var FPC = require('fingerprint-container-node-sdk2');
    var server = new FPC.Server('127.0.0.1','9090');
    
    // 增加一个rpc handler
    server.addHandler('ServiceName',function(res){
        //回复调用的client
        res.send({
            words: "hello world!"
        });

        server.destroy();
    });
    
    // 监听connect事件
    server.on('connect',function(){
        // connect成功后进行服务注册
        server.register();
    });
       
    // 注册成功回调
    server.on('register',function(){
        console.log('register success');
    });

Client API

    var FPC = require('fingerprint-container-node-sdk2');
    var client = new FPC.Client('127.0.0.1','9090');
    
    // 监听connect事件
    client.on('connect',function(){
        // connect成功后进行服务注册
        client.register();
    });
    
    // 注册成功回调
    client.on('register',function(){
        // 发送一个event事件给容器
        client.eventRequest('ServiceName', {
            name: 'event'
        });
        
        // 发送一个rpc给容器,timeout=2s, 等待server回复
        client.rpcRequest('ServiceName',{
            name: 'rpc'
        },function(body){
            console.log(body);
            client.destroy(); // 销毁client
        }, function(){
            console.log("timeout");
        },2000);
    });

#ClientPool API

    var FPC = require('fingerprint-container-node-sdk2');
    var pool = new FPC.ClientPool({
        host: '127.0.0.1',
        port: 8080,
        num: 5, // 启动多少client,默认为5
        name: 'mis', // Server名
        heartbeat: 30*1000 // 心跳检测轮询时间,用来剔除失活的链接
    });

    pool.acquire(function(client){
        client.rpcRequest('ServiceName',{
            name: 'rpc'
        },function(body){
            pool.release(client);
            console.log(body);
        }, function(){
            pool.release(client);
            console.log("timeout");
        },2000);
    });

Keywords

FAQs

Package last updated on 12 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc