This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Subscribe starting with most recently published value | |
sub, err := sc.Subscribe("eventstore.events", func(m *stan.Msg) { | |
fmt.Printf("Received a message: %s\n", string(m.Data)) | |
}, stan.StartWithLastReceived()) | |
// Receive all stored values in order | |
sub, err := sc.Subscribe("eventstore.events", func(m *stan.Msg) { | |
fmt.Printf("Received a message: %s\n", string(m.Data)) | |
}, stan.DeliverAllAvailable()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c *CommandBus) HandleCommand(cmd Command) { | |
events := c.CommandHandler.HandleCommand(cmd) | |
c.stan.Publish("eventstore.events", events) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub, err := sc.Subscribe("eventstore.events", func(m *stan.Msg) { | |
fmt.Printf("Received a message: %s\n", string(m.Data)) | |
// your code | |
if err := m.Ack(); err != nil { | |
// event is redelivered | |
return | |
} | |
}, | |
stan.maxInFlight(1), | |
stan.AckWait("30s"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub, err := sc.Subscribe("eventstore.events", func(m *stan.Msg) { | |
// check if event was already processed | |
if p.tracker.IsDuplicateOperation(p.name, event.ID) { | |
log.WithFields(eventLogFields).WithFields(subLogFields).Trace("duplicate") | |
if err := m.Ack(); err != nil { | |
log.WithFields(eventLogFields).WithFields(subLogFields).WithError(err).Error("ack duplicate event") | |
} | |
return | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub, err := sc.Subscribe("eventstore.events", func(m *stan.Msg) { | |
// TODO check if event was already processed | |
stan.PublishAsync("eventstore.events.order-projection", m.Data) | |
stan.PublishAsync("eventstore.events.order-reactor", m.Data) | |
// TODO track event as processed | |
// ack message | |
if err := m.Ack(); err != nil { | |
log.WithFields(eventLogFields).WithFields(r.baseLogFields).WithError(err).Error("ack event") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id | version | data | timestamp | |
+----+---------+----------------------------------------------------------------+---------------------+ | |
1 | 1 | {"PositionID": "Auftragsfreigabe", "PositionOrderID": "A1212"} | 1578079632531167629 | |
1 | 2 | {"PositionID": "Abteilung A", "PositionOrderID": "A1213"} | 1578079669618870080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* setImmediate callbacks are fired off the event loop, once per iteration in the order that they were queued. | |
* So on the first iteration of the event loop, callback A is fired. | |
* Then on the second iteration of the event loop, callback B is fired, then on the third iteration of the event loop callback C is fired, etc. | |
* This prevents the event loop from being blocked and allows other I/O or timer callbacks to be called in the mean time (as is the case of the 0ms timeout, which is fired on the 1st or 2nd loop iteration). | |
*/ | |
setImmediate(function A() { | |
setImmediate(function B() { | |
console.log(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: | |
enabled: true | |
type: LoadBalancer | |
# Additional annotations (e.g. for cloud provider specific config) | |
annotations: | |
load-balancer.hetzner.cloud/location: nbg1 | |
# ensure that the load balancer communicates via private network | |
load-balancer.hetzner.cloud/use-private-ip: "true" | |
# ensures that the load balancer is not removed | |
load-balancer.hetzner.cloud/name: "traefik" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.4' | |
services: | |
cypress: | |
container_name: 'cypress-e2e' | |
image: 'cypress/included:3.4.1' | |
working_dir: /e2e | |
volumes: | |
- .:/e2e | |
environment: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const assert = require('assert'); | |
/** | |
* The redis client is https://github.com/luin/ioredis | |
*/ | |
/* | |
const redisClient = new Redis({ |