An OMS template for NodeJS with subscription endpoints.
# Storyscript
your_service listen as srv
when srv heartbeat as event
log info event
# {"user": "max", "time": "..."}
# {"user": "moritz", "time": "..."}
# Storyscript
when your_service listen heartbeat user: 'Max' as event
log info event
# {"user": "max", "time": "..."}
# {"user": "max", "time": "..."}
# Storyscript
your_service publish eventName:'heartbeat' data:{'time': '...'}
> 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
> 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