Thriftily
A plugin for use thrift clients quickly and friendly with nodejs or eggjs.
Support: Node 10+,Eggjs
Useage
npm install thriftily -save
Common Config
const config = app: true // default true, use it with eggjs app agent: false // default false, use it with eggjs agent pinglog: true // default false,false is use logger.debug, ture is use logger.info print the ping log. default: // it will as default as all clients config reconnect: true // default true reconnectMaxTimes: 200 // default 0, 0 means no limit reconnectMaxSleep: 30000 // default 60000ms, reconnect sleep equals reconnect times multiplication 1000ms. host: '1.2.3.4' pingSleep: 5000 // default 10000ms clients: // clients config example, msFoo & msBar as alias name msFoo: host: 'foohost' port: 'fooport' client: yourFooGenjs ping: 'youpingName' // your ping method name in yourFooGenjs pingSleep: 5000 msBar: host: 'barhost' port: 'barport' client: yourBarGenjs
With Egg
config/plugin.js
moduleexportsthriftily = enable: true package: 'thriftily'
config/config.js
moduleexportsthriftily = thriftilyConfig // same as upper common config
Use in service
const Service = { const app = this const client = appthriftily try const res = await client catche console }
With Node
const ThriftilyManager = const thriftilyConfig = const manager = yourConfig yourLoggermanagerstart const client = manager try const res = await client catch e console