Coder Social home page Coder Social logo

ptzagk / node-events Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 23 KB

๐Ÿ“ƒ A template for creating Open Microservices with Node and event subscriptions

Home Page: https://openmicroservices.org

License: Other

Dockerfile 3.64% JavaScript 96.36%

node-events's Introduction

Microservice template for NodeJS with subscription endpoints

Microservice Build status

An OMS template for NodeJS with subscription endpoints.

Usage

Listen to all users

# Storyscript
your_service listen as srv
  when srv heartbeat as event
    log info event
# {"user": "max", "time": "..."}
# {"user": "moritz", "time": "..."}

Listen to a single user

# Storyscript
when your_service listen heartbeat user: 'Max' as event
  log info event
# {"user": "max", "time": "..."}
# {"user": "max", "time": "..."}

Publish events

# Storyscript
your_service publish eventName:'heartbeat' data:{'time': '...'}

Test

Subscribe to all user events

> oms subscribe listen heartbeat
โ„น Building Docker image
โ€ฆ
โœ” Built Docker image with name: oms/microservices/node-events
โœ” Started Docker container: 7be7d3cc4da6
โœ” Health check passed
โœ” Ran action: `listen` with output:
โœ” Subscribed to event: `heartbeat` data will be posted to this terminal window when appropriate
{
  "eventType": "heartbeat",
  "type": "com.microservices.node.template",
  "specversion": "0.2",
  "source": "/foo",
  "id": "NODE-TEMPLATE-0",
  "time": "2019-04-06T18:59:24.938Z",
  "datacontenttype": "application/json",
  "data": {
    "user": "max",
    "time": "Sat Apr 06 2019 18:59:24 GMT+0000 (Coordinated Universal Time)"
  }
}
{
  "eventType": "heartbeat",
  "type": "com.microservices.node.template",
  "specversion": "0.2",
  "source": "/foo",
  "id": "NODE-TEMPLATE-1",
  "time": "2019-04-06T18:59:26.938Z",
  "datacontenttype": "application/json",
  "data": {
    "user": "moritz",
    "time": "Sat Apr 06 2019 18:59:26 GMT+0000 (Coordinated Universal Time)"
  }
}
โ€ฆ
โœ” Stopped Docker container: 7be7d3cc4da6

Subscribe to all individual user events

> oms subscribe listen heartbeat -a user='max'
โ„น Building Docker image
โ€ฆ
โœ” Built Docker image with name: oms/microservices/node-events
โœ” Started Docker container: 5d2592cbd82b
โœ” Health check passed
โœ” Ran action: `listen` with output:
โœ” Subscribed to event: `heartbeat` data will be posted to this terminal window when appropriate
{
  "eventType": "heartbeat",
  "type": "com.microservices.node.template",
  "specversion": "0.2",
  "source": "/foo",
  "id": "NODE-TEMPLATE-0",
  "time": "2019-04-06T19:04:00.845Z",
  "datacontenttype": "application/json",
  "data": {
    "user": "max",
    "time": "Sat Apr 06 2019 19:04:00 GMT+0000 (Coordinated Universal Time)"
  }
}
{
  "eventType": "heartbeat",
  "type": "com.microservices.node.template",
  "specversion": "0.2",
  "source": "/foo",
  "id": "NODE-TEMPLATE-1",
  "time": "2019-04-06T19:04:03.844Z",
  "datacontenttype": "application/json",
  "data": {
    "user": "max",
    "time": "Sat Apr 06 2019 19:04:03 GMT+0000 (Coordinated Universal Time)"
  }
}
โ€ฆ
โœ” Stopped Docker container: 5d2592cbd82b

node-events's People

Contributors

matthewhudson avatar renovate-bot avatar wilzbach avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.