Last active
January 4, 2020 19:20
-
-
Save StarpTech/3947d8ce649089cea3c2c7d56324a57c to your computer and use it in GitHub Desktop.
Replay events
This file contains hidden or 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()) | |
// Receive messages starting at a specific sequence number | |
sub, err := sc.Subscribe("eventstore.events", func(m *stan.Msg) { | |
fmt.Printf("Received a message: %s\n", string(m.Data)) | |
}, stan.StartAtSequence(22)) | |
// Subscribe starting at a specific time | |
var startTime time.Time | |
... | |
sub, err := sc.Subscribe("eventstore.events", func(m *stan.Msg) { | |
fmt.Printf("Received a message: %s\n", string(m.Data)) | |
}, stan.StartAtTime(startTime)) | |
// Subscribe starting a specific amount of time in the past (e.g. 30 seconds ago) | |
sub, err := sc.Subscribe("eventstore.events", func(m *stan.Msg) { | |
fmt.Printf("Received a message: %s\n", string(m.Data)) | |
}, stan.StartAtTimeDelta(time.ParseDuration("30s"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment