bullma.js

0.1.0 • Public • Published

What is Bullma?

  • Open source framework for building event-driven microservices.
  • Scalability the code is automatically scalable with no change in the code.
  • Availability as long as the cluster is running and there are instances everything is fine!
  • Durability events can't be lost even after a cluster reboot. (TODO:Migration to NATS Jetstream)
  • Easy deploy your application without modifying the code.
Bullma is a new way of writing backend.

How to install?

1. Run the nats-server Docker image.

> docker run -p 4222:4222 -p 8222:8222 -p 6222:6222 --name nats-server -ti nats:latest

2. Install the package inside your project

> npm i  @diffty/bullma
// or
> yarn add @diffty/bullma

And.. Finish!!

Example

require("@diffty/bullma")(
  "namespace1",
  /* optional */ {
    transport: {
      // nats config
      servers: ["127.0.0.1:4222"],
    },
    config: {
      // global config
      whoami: "I'm bullma",
    },
  }
)
  .then((Service) => {
    Service(
      "myservice1",
      async (config, exports, emit) => {
        console.log("init", "myservice1");
        exports("gettime", () => Date.now());
        exports.myservice2.on("testevent", (...msg) => {
          console.log("myservice1", "testevent", ...msg);
        });
      },
      /* optional */ {
        mylocalvar1: "test1",
      }
    );
    Service(
      "myservice2",
      async (config, exports, emit) => {
        console.log("init", "myservice2");
        console.log("myservice2", await exports.myservice1.gettime());
        emit("testevent", "hello world", "mdr", 12);
      },
      /* optional */ {
        mylocalvar1: "test2",
      }
    );
  })
  .catch(console.log);

How to contribute?

License

Apache License v2.0

Package Sidebar

Install

npm i bullma.js

Weekly Downloads

0

Version

0.1.0

License

Apache-2.0

Unpacked Size

63.8 kB

Total Files

19

Last publish

Collaborators

  • aabbdev