ovis-log
v0.1.5
Published
log
Downloads
3
Readme
mq
api
init(ctx, timingType)
subscribe('topic', subScribeFunction)
publish('topic', dataOrFn)
params
const ctx = {} // Some objects you might use, such as mongodb instances
const topic = '' // patterns
const timing = [
'second', // default
'minute',
'hour',
'day'
]
const subScribeFunction = (params, ctx) => {}
const dataOrFn = params || (ctx) => {}
use
init({ name: 'ctxName' }, 'minute')
subscribe(
'testTopic',
(data, ctx) => console.log(`${data.name} : ${ctx.name}) // "passName : ctxName"
)
publish('testTopic', { name: 'passName' }) // publish immediately
publish('testTopic', { name: 'passName' }, 1) // after one minute
publish('testTopic', { name: 'passName' }, 2) // after two minute