plimble / natses

Event Sourcing with NATS Streaming

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

natses

Event Sourcing with NATS Streaming

Installation

go get github.com/plimble/natses

Usage

// Pub
sc, _ := stan.Connect(clusterID, clientID)

data, _ := natses.NewEvent("Registered", registeredEvent)
sc.Publish("foo", data)

data, _ = natses.NewEvent("EmailUpdated", emailUpdatedEvent)
sc.Publish("foo", data)
// Sub

sc.Subscribe("foo", natses.SubEvent(UserEvent))

func UserEvent(msg natses.EventMsg) {
  switch msg.EventType {
  case "Registered":
    ...
  case "EmailUpdated":
    ...
  }
}

About

Event Sourcing with NATS Streaming

License:MIT License


Languages

Language:Go 98.6%Language:Protocol Buffer 1.4%