Skip to content

Instantly share code, notes, and snippets.

@soheilhy
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soheilhy/84ea8c884cded9c6b3a8 to your computer and use it in GitHub Desktop.
Save soheilhy/84ea8c884cded9c6b3a8 to your computer and use it in GitHub Desktop.
Register taskq handlers (simple)
app := beehive.NewApp("taskq")
app.Handle(Enque{}, EnQHandler{})
app.Handle(Deque{}, DeQHandler{})
app.Handle(Ack{}, AckHandler{})
app.Handle(Timeout{}, TimeoutHandler{
ExpDur: 60 * time.Second,
})
// Detached runs a local go-routine, and NewTimer
// creates a "detached" handler that calls the function
// every 30 seconds.
app.Detached(beehive.NewTimer(30*time.Second, func() {
beehive.Emit(Timeout(time.Now()))
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment