1.0.5 • Published 6 years ago

middleware_common_infrastructure v1.0.5

Weekly downloads
-
License
AGPL-3.0
Repository
-
Last release
6 years ago

middleware-common-infrastructure Build Status

Infrastructure classes for middleware services

AmqpService

service for bind on amqp (rabbitmq) and publish messages.

How to work

Create and bind

const rabbit = new AmqpService('amqp://localhost:5672', 'internal', 'infrastructure');
await rabbit.start();
await rabbit.addBind('blockProcessor', 'BLOCK_PROCESSOR');
rabbit.on('BLOCK_PROCESSOR', data => {
    console.log(data);
});
await rabbit.delBind('blockProcessor');
await rabbit.close();

Create and publish

const rabbit = new AmqpService('amqp://localhost:5672', 'internal', 'infrastructure');
await rabbit.start();
await rabbit.publishMsg('blockProcessor', {msg: 'test msg'});
await rabbit.close();

InfrastructureInfo

Service for parsing parameters for InfrastructureService from package.json

How to work

const info = new InfrastructureInfo(require('./package.json'));

InfrastructureService

service for start infrastructure

This service checked all requirements of middleware through checkInterval by rabbitmq
    If at least for one middleware name not found required major version
        service emit EVENT=InfrastuctureService.REQUIREMENT_ERROR
        with data = {requirement: object of Requirement, version: last returned version}

Also this service send own version when get request from another middleware by rabbitmq

How to work

const rabbit = new AmqpService('amqp://localhost:5672', 'internal', 'infrastructure');
const info = InfrastructureInfo(require('./package.json'));
const infrastructure = new InfrastructureService(info, rabbit, {checkInterval: 10000});
await infrastructure.start();
infrastructure.on(infrastructure.REQUIREMENT_ERROR, ({requirement, version}) => {
log.error(`Not found requirement with name ${requirement.name} version=${requirement.version}.` +
    ` Last version of this middleware=${version}`);
process.exit(1);
});
await infrastructure.checkRequirements();
infrastructure.periodicallyCheck();

How close infrastructure

await infrastucture.close();

License

GNU AGPLv3

Copyright

LaborX PTY

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago