{"id":20572031,"url":"https://github.com/netease/pomelo-rpc-zeromq","last_synced_at":"2026-03-04T09:31:02.294Z","repository":{"id":14228004,"uuid":"16935011","full_name":"NetEase/pomelo-rpc-zeromq","owner":"NetEase","description":"pomelo rpc using zeromq for communication","archived":false,"fork":false,"pushed_at":"2014-11-22T08:10:33.000Z","size":203,"stargazers_count":12,"open_issues_count":2,"forks_count":19,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-21T18:01:14.818Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NetEase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-18T02:57:32.000Z","updated_at":"2025-03-07T11:23:43.000Z","dependencies_parsed_at":"2022-08-30T09:41:16.107Z","dependency_job_id":null,"html_url":"https://github.com/NetEase/pomelo-rpc-zeromq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NetEase/pomelo-rpc-zeromq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetEase%2Fpomelo-rpc-zeromq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetEase%2Fpomelo-rpc-zeromq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetEase%2Fpomelo-rpc-zeromq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetEase%2Fpomelo-rpc-zeromq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NetEase","download_url":"https://codeload.github.com/NetEase/pomelo-rpc-zeromq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetEase%2Fpomelo-rpc-zeromq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30077064,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T08:01:56.766Z","status":"ssl_error","status_checked_at":"2026-03-04T08:00:42.919Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T05:18:05.914Z","updated_at":"2026-03-04T09:31:02.271Z","avatar_url":"https://github.com/NetEase.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"pomelo-rpc-zeromq\n=================\n\npomelo-rpc-zeromq is the low level RPC framework for pomelo project. It contains two parts: client and server.\n\nThe client part generates the RPC client proxy, routes the message to the appropriate remote server and manages the network communications. Support add proxies and remote server information dynamically.\n\nThe server part exports the remote services, dispatches the remote requests to the services and also manages the network communications.\n\nAnd the remote service codes would loaded by pomelo-loader module and more details please access this [link](https://github.com/node-pomelo/pomelo-loader).\n\n+ Tags: node.js\n\n##Installation\n```\nnpm install pomelo-rpc-zeromq\n```\n\n##Usage\n\nYou must make sure that zeromq has been installed.\n\n###Server\n``` javascript\nvar Server = require('pomelo-rpc-zeromq').server;\n\n// remote service path info list\nvar paths = [\n  {namespace: 'user', path: __dirname + '/remote/test'}\n];\n\nvar port = 3333;\n\nvar server = Server.create({paths: paths, port: port});\nserver.start();\nconsole.log('rpc server started.');\n```\n\n###Client\n``` javascript\nvar Client = require('pomelo-rpc-zeromq').client;\n\n// remote service interface path info list\nvar records = [\n  {namespace: 'user', serverType: 'test', path: __dirname + '/remote/test'}\n];\n\n// server info list\nvar servers = [\n  {id: 'test-server-1', serverType: 'test', host: '127.0.0.1', port: 3333}\n];\n\n// route parameter passed to route function\nvar routeParam = null;\n\n// route context passed to route function\nvar routeContext = servers;\n\n// route function to caculate the remote server id\nvar routeFunc = function(routeParam, msg, routeContext, cb) {\n  cb(null, routeContext[0].id);\n};\n\nvar client = Client.create({routeContext: routeContext, router: routeFunc});\n\nclient.start(function(err) {\n  console.log('rpc client start ok.');\n\n  client.addProxies(records);\n  client.addServers(servers);\n\n  client.proxies.user.test.service.echo(routeParam, 'hello', function(err, resp) {\n    if(err) {\n      console.error(err.stack);\n    }\n    console.log(resp);\n  });\n});\n```\n\n##Server API\n###Server.create(opts)\nCreate a RPC server instance. Intitiate the instance and acceptor with the configure.\n###Parameters\n+ opts.port - rpc server listening port.\n+ opts.paths - remote service path infos, format: [{namespace: remote service namespace, path: remote service path}, ...].\n+ opts.context - remote service context.\n+ opts.acceptorFactory(opts, msgCB) - (optional) acceptor factory method. opts.port：port that acceptor would listen，opts.services：loaded remote services，format: {namespace: {name: service}}. msgCB(msg, cb): remote request arrived callback. the method should return a acceptor instance.\n\n###server.start\nStart the remote server instance.\n\n###server.stop\nStop the remote server instance and the acceptor.\n\n###Acceptor\nImplement the low level network communication with specified protocol. Customize the protocol by passing an acceptorFactory to return different acceptors.\n\n###acceptor.listen(port)\nListen the specified port.\n\n###acceptor.close\nStop the acceptor.\n\n##Client API\n###Client.create(opts)\nCreate an RPC client instance which would generate proxies for the RPC client.\n####Parameters\n+ opts.context - context for mailbox.\n+ opts.routeContext - (optional)context for route function.\n+ opts.router(routeParam, msg, routeContext, cb) - (optional) route function which decides the RPC message should be send to which remote server. routeParam: route parameter, msg: RPC descriptioin message, routeContext: opts.routeContext.\n+ opts.mailBoxFactory(serverInfo, opts) - (optional) mail box factory method.\n\n###client.addProxies(records)\nLoad new proxy codes.\n####Parameters\n+ records - new proxy code configure information list。Format: [{namespace: service_name_space, serverType: remote_server_type, path: path_to_remote_service_interfaces}];\n\n###client.addServers(servers)\nAdd new remote server informations.\n####Parameters\n+ servers - remote server information list. Format: [{id: remote_server_id, serverType: remote_server_type, host: remote_server_host, port: remote_server_port}]\n\n###client.start(cb)\nStart the RPC client.\n\n###client.stop\nStop the RPC client and stop all the mail box connections to remote servers.\n\n###client.rpcInvoke(serverId, msg, cb)\nInvoke an RPC request.\n####Parameters\n+ serverId - remote server id.\n+ msg - RPC description message. format: {namespace: remote service namespace, serverType: remote server type, service: remote service name, method: remote service method name, args: remote service args}.\n+ cb - remote service callback function.\n\n###MailBox\nImplement the low level network communication with remote server. A mail box instance stands for a remote server. Customize the protocol by passing a mailBoxFactory parameter to client to return different mail box instances.\n\n###mailbox.connect(cb)\nConnect to the remote server.\n\n###mailbox.close\nClose mail box instance and disconnect with the remote server.\n\n###mailbox.send(msg, opts, cb)\nSend the RPC message to the associated remote server.\n####Parameters\n+ msg - RPC description message, see also clienet.rpcInvoke.\n+ opts - reserved.\n+ cb - RPC callback function.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetease%2Fpomelo-rpc-zeromq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetease%2Fpomelo-rpc-zeromq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetease%2Fpomelo-rpc-zeromq/lists"}