Skip to content

memsql/keyeddistributor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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