https://github.com/vectorhacker/goro
Go client library for EventStore.
https://github.com/vectorhacker/goro
event-sourcing eventsourcing eventstore golang golang-library golang-package goro stream-processing streaming
Last synced: 5 months ago
JSON representation
Go client library for EventStore.
- Host: GitHub
- URL: https://github.com/vectorhacker/goro
- Owner: vectorhacker
- License: mit
- Created: 2017-12-15T02:13:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-14T06:20:41.000Z (over 7 years ago)
- Last Synced: 2024-06-19T18:10:59.605Z (almost 2 years ago)
- Topics: event-sourcing, eventsourcing, eventstore, golang, golang-library, golang-package, goro, stream-processing, streaming
- Language: Go
- Homepage:
- Size: 9 MB
- Stars: 11
- Watchers: 5
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Goro
====
[](https://godoc.org/github.com/vectorhacker/goro)
[](https://travis-ci.org/vectorhacker/goro)
[](https://goreportcard.com/report/github.com/vectorhacker/goro)
[](https://coveralls.io/github/vectorhacker/goro?branch=master)
Goro is a [Go](http://golang.org) client library for [Event Store](http://eventstore.org).
[Godoc](https://godoc.org/github.com/vectorhacker/goro)
Example:
----
```go
package main
import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/vectorhacker/goro"
)
func main() {
// create a client to use the Event Store
client := goro.Connect("http://localhost:2113", goro.WithBasicAuth("admin", "changeit"))
writer := client.Writer("messages")
reader := client.FowardsReader("messages")
catchupSubscription := client.CatchupSubscription("messages", 0) // start from 0
data := []byte("{\"message\": \"hello world\"}")
// write the event
ctx := context.Background()
event := goro.CreateEvent(
"message",
data,
nil, // nil metadata
0,
)
err = writer.Write(ctx, goro.ExpectedVersionAny, event)
if err != nil {
panic(err)
}
// subscribe to a stream of events
go func() {
ctx := context.Background()
messages := catchupSubscription.Subscribe(ctx)
for message := range messages {
fmt.Printf("%s\n", messages.Event.Data)
}
}()
// read events
events, err := reader.Read(ctx, 0, 1)
if err != nil {
panic(err)
}
for _, event := range events {
fmt.Printf("%s\n", event.Data)
}
}
```
TODO
---
- [x] Tests
- [x] Competing Consumers
- [ ] Projections
- [x] Read Events
- [x] Stream Events
- [x] Write Events
- [ ] User Management