GOES is an Event Store golang TCP Library for Go.
//connect to a single node
config := &goes.Configuration{
ReconnectionDelay: 10000,
MaxReconnects: 10,
MaxOperationRetries: 10,
Address: "127.0.0.1",
Port: 1113,
Login: "admin",
Password: "changeit",
}
//or a cluster via gossip seeds
config := &goes.Configuration{
ReconnectionDelay: 10000,
MaxReconnects: 10,
MaxOperationRetries: 10,
Login: "admin",
Password: "changeit",
EndpointDiscoverer: discoverer = goes.GossipEndpointDiscoverer{
MaxDiscoverAttempts: 10,
GossipSeeds: []string{"http://127.0.0.1:2113", "http://127.0.0.1:1113"},
}
}
conn, err := goes.NewEventStoreConnection(config)
if err != nil {
log.Fatalf("[fatal] %s", err.Error())
}
err = conn.Connect()
defer conn.Close()
if err != nil {
log.Fatalf("[fatal] %s", err.Error())
}
events := []goes.Event{
goes.Event{
EventID: uuid.NewV4(),
EventType: "itemAdded",
IsJSON: true,
Data: []byte("{\"price\": \"100\"}"),
Metadata: []byte("metadata"),
},
goes.Event{
EventID: uuid.NewV4(),
EventType: "itemAdded",
IsJSON: true,
Data: []byte("{\"price\": \"120\"}"),
Metadata: []byte("metadata"),
},
}
result, err := goes.AppendToStream(conn, "shoppingCart-1", -2, events)
if *result.Result != protobuf.OperationResult_Success {
log.Printf("[info] WriteEvents failed. %v", result.Result.String())
}
if err != nil {
log.Printf("[error] WriteEvents failed. %v", err.Error())
}
goes.ReadSingleEvent(conn, "$stats-127.0.0.1:2113", 0, true, true)
Licenced under MIT.