Godiator is Simple Pub&Sub implementation For Golang.
go get github.com/blueskan/godiator
package main
import (
"fmt"
. "github.com/blueskan/godiator"
)
func main() {
godiator := NewGodiator()
// Subscription
godiator.
Subscribe("notification:user:registration", func(event Event) {
// E-mail handler
fmt.Println(event.Payload.(string) + ": Sending email...")
}).
Subscribe("notification:user:registration", func(event Event) {
// Sms handler
fmt.Println(event.Payload.(string) + ": Sending sms...")
})
// Publish
godiator.Publish(Event{
Name: "notification:user:registration",
Payload: "New user created",
})
}
You can send any type of payload maps, arrays, another structs or even nil (default value)
https://godoc.org/github.com/blueskan/godiator
- Async message handling (just for now it's just handling sync)
- Any pull requests or ideas will be appreciated