npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rotorsoft/eventually-broker

v2.3.1

Published

Eventually Framework Broker Service

Downloads

205

Readme

eventually-broker

NPM Version

Message Broker

This library implements a very simple message broker abstraction that centralizes system configuration, service discovery, contract mapping, and basic observability. It uses a pull-push communication pattern that connects event streams from producers to consumers at a higher (system) level. Services don't need to know about this abstraction, they just produce or react to interesting things that happen (events).

Unlike other message brokers, like Kafka or RabbitMQ, this broker doesn't store messages in queues or streams. Eventually services own their event stores, and the broker just connects the streams.

The broker uses Pull Channels to listen to and pull from producing services, and Push Channels to push to consumers.

Framework Ports

Services and Subscriptions

TODO: Documentation

Service Paths

  • GET /services - Lists all services
  • GET /services/:id - Shows service with id, admins can edit
  • GET /services/:id/events - Queries service events
  • GET /services/:id/events/:eid - Gets service event by id
  • GET /services/:id/stream/:sid - Queries service stream
  • GET /services?add=true - Admins can add new services
  • POST /services - Adds a new service
  • POST /services/:id - Updates an existing service
  • DELETE /services/:id - Deletes existing service

Subscription Paths

  • GET /subscriptions - Lists all subscriptions
  • GET /subscriptions/:id - Shows subscription with id, admins can edit
  • GET /subscriptions?add=true - Admins can add new subscription
  • GET /subscriptions?search=criteria - Filters subscriptions by criteria
  • POST /subscriptions - Adds a new subscription
  • POST /subscriptions/:id - Updates an existing subscription
  • DELETE /subscriptions/:id - Deletes existing subscription

Services Graph

TODO: Documentation

  • GET /graph

Correlation Explorer

TODO: Documentation

  • GET /correlations/:id

Contracts Explorer

  • GET /contracts

Discovering Service Contracts

The broker automatically polls HTTP services every 30 seconds at GET /swagger and expects a JSON representation of the OpenAPI Spec3. It uses this data to consolidate event contracts into a single view. The spec interpreter follows these simple conventions:

  • All event schemas (consumed or produced) by the service are included in the spec components section #/components/schemas
  • All event handler paths are represented as POST methods and include references #ref to consumed event schemas in the requestBody
  • Events not found referenced by handler paths are considered events produced by this service
  • All event schemas are object types with the following fields:
    • name: string - constrained by enum with the event name
    • created: datetime
    • data: (optional) - event payload schema

Example

{
  "openapi": "3.0.3",
  "info": {
    "title": "calculator",
    "version": "1.0.0",
    "description": "Calculator API"
  },
  ...
  "components": {
     ...
    "schemas": {
      ... 
      "DigitPressed": {
        "type": "object",
        "properties": {
          "name": { "type": "string", "enum": ["DigitPressed"] },
          "id": { "type": "integer" },
          "stream": { "type": "string" },
          "version": { "type": "integer" },
          "created": { "type": "string", "format": "date-time" },
          "data": {
            "type": "object",
            "properties": {
              "digit": {
                "type": "string",
                "enum": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
              }
            },
            "required": ["digit"],
            "additionalProperties": false
          }
        },
        "required": ["name", "id", "stream", "version", "created", "data"],
        "additionalProperties": false,
        "name": "DigitPressed",
        "description": "Generated when a **digit** is pressed\n\nThis is and example to use\n* markup language\n* inside descriptions"
      },
      "OperatorPressed": {
        "type": "object",
        "properties": {
          "name": { "type": "string", "enum": ["OperatorPressed"] },
          "id": { "type": "integer" },
          "stream": { "type": "string" },
          "version": { "type": "integer" },
          "created": { "type": "string", "format": "date-time" },
          "data": {
            "type": "object",
            "properties": {
              "operator": { "type": "string", "enum": ["+", "-", "*", "/"] }
            },
            "required": ["operator"],
            "additionalProperties": false
          }
        },
        "required": ["name", "id", "stream", "version", "created", "data"],
        "additionalProperties": false,
        "name": "OperatorPressed",
        "description": "Generated when operator is pressed"
      }
      ...
    }
  },
  "paths": {
    ...
    "/counter": {
      "post": {
        "operationId": "Counter",
        "tags": ["Counter"],
        "summary": "Handle Counter Events",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  { "$ref": "#/components/schemas/DigitPressed" },
                  ...
                  { "$ref": "#/components/schemas/OperatorPressed" }
                ]
              }
            }
          }
        },
        ...
      }
    }
  }
}

APIs

  • GET /api/events

Customizing the Broker

TODO: Document how to customize application with injected handlers, middleware, secrets, etc.