@eve-bc/core
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Readme

Introduction

eve-bc is a tool to get more data out of your microservices. It serves as a starting point to log messages anywhere.

TL;DR

  • Create an instance and connect plugins
  • Fire broadcasts as desired
  • Stop all instaces if closing the application

Installation

$ npm i @eve-bc/core

How to use

const bc = new ServiceBroadcast('demo-service');
bc.usePlugin(new ConsolePlugin());
await bc.init();

await bc.announce({
    type: BroadcastType.ATTEMPT,
    message: 'fetch a user from a database',
    recipient: { type: 'Database', name: 'default-sql' },
    metadata: { query: 'SELECT 1 = 1' }
});

await bc.stop();

Plugins

eve-bc works using a plugin system. After a broadcast is created, distribution of said broadcast is up to the developer. There are Two predefined Plugins:

Console

Leads any event directly into the console to log it.

In-memory-DB

stores any event into an array which is stored in memory. THis is mostly for demonstration purposes.

Writing your own

You can write your own plugins using the BroadcastPlugin class:

class MyPlugin extends BroadcastPlugin {
    public async init(): Promise<void> {
        // initialisation logic
    }

    public announce(broadcast: Broadcast): Promise<void> {
        // handle how a broadcast is being sent. 
    }
    
    public stop(): Promise<void> {
        // handle cleanup logic
    }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @eve-bc/core

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

25.9 kB

Total Files

50

Last publish

Collaborators

  • codingvampyre