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

vein-rpc

v1.0.8

Published

Vein RPC远程方法调用模块

Downloads

23

Readme

Vein-RPC

介绍

橡芮科技Vein RPC远程功能调用模块,在同一局域网中可自动发现Master节点

模块划分

Master模块

RPC服务管理模块,用于RPC中心节点

Provider模块

RPC服务提供模块,用于提供RPC方法供服务消费者调用

Consumer模块

RPC服务消费模块,可对在Master中心节点中注册的远程服务方法进行调用

代码示例

Master
(async () => {
	const master = new Master({port: 65388, token: 'test-token-not-necessary'})
	await master.launch()
	console.log('master launched')
})()
Provider
(async () => {
	const functionMap = new Map()
	functionMap.set({a: true, b: false}, async (data) => {
		return data.x + data.y
	})

	const provider = new Provider({
		patternFunctionMap: functionMap,
		serviceName: 'com.example.service1',
		port: 65388,
		token: 'test-token-not-necessary'
	})
	console.log('Provider ready')
})()
Consumer
(async () => {
	const consumer = new Consumer({port: 65388, token: 'test-token-not-necessary'})
	const res = await consumer.invoke('com.example.service1', {
		a: true,
		b: false,
		x: 10,
		y: 99
	}, {
		allowRetry: true,
		maxRetry: 10,
		retryDelay: 100,
		ignoreConnectionError: true,
		timeout: 300000,
		offlinePending: true
	})
	console.log('result', res)
})()

Class

Master
new Master([options])
  • options?: { token?: string, port?: number }
master.fetchProviders()

获取服务中心节点所持有的Providers信息

Provider
new Provider(options)
  • options: { serviceName: string, patternFunctionMap: PatternFunctionMap, registries?: Array | string, token?: string, port?: number }

| Type | 数据类型 | 说明 | | ---- | ---- | ---- | | Pattern | { [key: string]: any } | 无 | | PatternFunctionMap | Map<Pattern, (input: { [key: string]: any }) => Promise> | 无 |

provider.fetchRegistries()

获取服务提供者所连接的Registries信息

Consumer
new Consumer([options])
  • options?: { registries?: Array | string, port?: number, token?: string }
consumer.registryInfo()

获取服务消费者当前连接的Registries信息

async consumer.invoke(serviceName, data [, options])
  • serviceName: string

  • data: { [key: string]: any }

  • options: InvokeOptions

| 选项 | 数据类型 | 默认值 | 说明 | | ---- | ---- | ---- | ---- | | allowRetry | boolean | true | 是否允许请求失败时重试 | | maxRetry | number | 10 | 最大重试次数 | | ignoreConnectionError | boolean | true | 是否忽略连接错误 | | retryDelay | number | 100 | 重试时间间隔(毫秒) | | timeout | number | 300000 | 请求超时时间(毫秒) | | offlinePending | boolean | true | 是否在未连接至Registry时将操作搁置 |

注意事项

  • 在使用PM2的cluster模式时可能会出现未知的问题