1.1.2 • Published 7 years ago

octobus.js v1.1.2

Weekly downloads
130
License
MIT
Repository
github
Last release
7 years ago

Octobus.js

travis build

Octobus is a javascript library that helps you keep your code modular and extensible by creating services that respond to messages.

Install

npm install octobus.js

Key principles:

  • functions with named arguments are preferred to functions with positional arguments
  • promises are better than callbacks (they help you get rid of callback hell)
  • async / await calls are better than promises alone and will make you code more readable and manageable
  • service functions (handlers) as first class citizens
  • inheritance is great when used with good care; composition is even better.

Benefits:

  • promotes high decoupling between the sender and the receiver of the message
  • logging and introspection of the messages
  • microservices friendly
  • dependency injection of other services
  • ability to extend existing services
  • service calls interception
  • extensions (octobus-crud, hapi-octobus etc.)
  • everything is asynchronous (promises, async / await)

Requirements:

  • octobus.js requires node >= 6 because of its Proxy use.

How to use it:

1) First we need to create a MessageBus instance. We use it to send message to services.

import { MessageBus } from 'octobus.js';
const messageBus = new MessageBus();

2) We create a ServiceBus and connect it to our MessageBus instance. This service bus will proxy the message sending to the message bus and its main use is to group together handlers of a specific area of the business logic.

import { ServiceBus } from 'octobus.js';
const serviceBus = new ServiceBus();
serviceBus.connect(messageBus);

2) We create services, which are functions that can listen and act on a specific topic.

serviceBus.subscribe('hello', ({ message }) => `Hello, ${message.data}!`);

3) Now we are able to send message to be handled by the services we previously defined.

serviceBus.send('hello', 'world').then((result) => {
  console.log(result); // will output "Hello, world!"
});

Read more about it.

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.32.0

7 years ago

0.31.1

7 years ago

0.31.0

7 years ago

0.30.0

7 years ago

0.29.0

7 years ago

0.28.0

7 years ago

0.27.0

7 years ago

0.26.1

7 years ago

0.26.0

7 years ago

0.25.0

7 years ago

0.24.0

7 years ago

0.23.0

7 years ago

0.22.1

7 years ago

0.22.0

7 years ago

0.21.1

7 years ago

0.21.0

7 years ago

0.20.0

7 years ago

0.19.0

7 years ago

0.18.2

7 years ago

0.18.1

7 years ago

0.18.0

7 years ago

0.17.1

8 years ago

0.17.0

8 years ago

0.16.3

8 years ago

0.16.2

8 years ago

0.16.1

8 years ago

0.16.0

8 years ago

0.15.0

8 years ago

0.14.8

8 years ago

0.14.7

8 years ago

0.14.6

8 years ago

0.14.5

8 years ago

0.14.4

8 years ago

0.14.3

8 years ago

0.14.2

8 years ago

0.14.1

8 years ago

0.14.0

8 years ago

0.13.0

8 years ago

0.12.1

8 years ago

0.12.0

8 years ago

0.11.1

8 years ago

0.11.0

8 years ago

0.10.2

8 years ago

0.10.1

8 years ago

0.10.0

8 years ago

0.9.0

8 years ago

0.8.0

8 years ago

0.7.1

8 years ago

0.7.0

8 years ago

0.6.2

8 years ago

0.6.1

8 years ago

0.6.0

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago