Reconnect on error (stop only with context):
ctx, cancel := context.WithCancel(context.Background())
client := eventstream.NewClient()
stream := client.RevisionCreate(ctx, time.Now(), func(evt *events.RevisionCreate) {
fmt.Println(evt)
})
go func() {
time.Sleep(2 * time.Second)
cancel()
}()
for err := range stream.Sub() {
fmt.Println(err)
}
Exit on error:
client := eventstream.NewClient()
stream := client.PageDelete(context.Background(), time.Now(), func(evt *events.PageDelete) {
fmt.Println(evt.Data)
})
err := stream.Exec()
if err != nil {
log.Panic(err)
}
For more information about the stream and how to use it visit EventStreams documentation.