Notifier for octopod
Install
npm install @octopod-service/notifier
Usage
import * as notifier from '@octopod-service/notifier'
const notifier = require('@octopod-service/notifier');
const notifierService = new notifier.NotifierService('http://...');
notifierService.operations.push({
type: 'write-file',
settings: {
path: '...'
}
});
notifierService.types['write-file'] = function(type , data , callback )
{
if(!type.settings.path)
{
this.error('Error in "write-file"', 'type.settings.path is not defined');
return callback();
}
const retry = () => {
require('fs').writeFile(type.settings.path, JSON.stringify(data), (e) => {
if(!e)
return callback();
this.error('Error in "write-file"', e);
return setTimetout(() => retry(), type.retryTimeout ? type.retryTimeout : 10000);
})
}
retry();
}
notifierService.start();