Skip to content

Instantly share code, notes, and snippets.

@soheilhy
Last active August 29, 2015 14:25
Show Gist options
  • Save soheilhy/bb9c655e03230b611034 to your computer and use it in GitHub Desktop.
Save soheilhy/bb9c655e03230b611034 to your computer and use it in GitHub Desktop.
Register taskq handler (full)
// RegisterTaskQ registers the taskq application and all its handler in the
// hive.
func RegisterTaskQ(h beehive.Hive) {
a := h.NewApp("taskq", beehive.Persistent(3))
a.Handle(Enque{}, EnQHandler{})
a.Handle(Deque{}, DeQHandler{})
a.Handle(Ack{}, AckHandler{})
a.Handle(Timeout{}, TimeoutHandler{
ExpDur: 60 * time.Second,
})
a.Detached(beehive.NewTimer(30*time.Second, func() {
h.Emit(Timeout(time.Now()))
}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment