Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 1.07 KB

README.md

File metadata and controls

30 lines (21 loc) · 1.07 KB

keyeddistributor - distribute events to listeners by key

GoDoc unit tests report card codecov

Install:

go get github.com/memsql/keyeddistributor

Keyeddistributor is an add-on to eventdistributor that allows for ad-hoc subscription to events that match a key value.

An example

keyed := keyeddistributor.New(func(t Thing) ThingKey) {
	return t.Key // or whatever is needed to extract a ThingKey from a Thing
})

reader := keyed.Subscribe("some key value")
defer reader.Unsubscribe()

<-reader.WaitChan()
thing := reader.Consume()
// do stuff with thing