Last active
March 1, 2017 05:20
-
-
Save aalvesjr/198dbb2679b2ac297d47227ea4be741c to your computer and use it in GitHub Desktop.
Example of NSQ emitter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/rafaeljesus/nsq-event-bus" | |
"log" | |
) | |
type event struct{ Body string } | |
func main() { | |
topic := "events" | |
emitter, err := bus.NewEmitter(bus.EmitterConfig{}) | |
if err != nil { | |
log.Fatal("[ERRO]", err) | |
} | |
message := "[Emitter 1] sending message" | |
e := event{message} | |
if err = emitter.Emit(topic, &e); err != nil { | |
log.Println("error while was emitting message", err) | |
} | |
log.Println("[Message emitted]", message) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment