An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

Goro
====
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/vectorhacker/goro)
[![Build Status](https://travis-ci.org/vectorhacker/goro.svg?branch=master)](https://travis-ci.org/vectorhacker/goro)
[![Go Report Card](https://goreportcard.com/badge/github.com/vectorhacker/goro)](https://goreportcard.com/report/github.com/vectorhacker/goro)
[![Coverage Status](https://coveralls.io/repos/github/vectorhacker/goro/badge.svg?branch=master)](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