Last active
August 29, 2015 14:25
-
-
Save soheilhy/84ea8c884cded9c6b3a8 to your computer and use it in GitHub Desktop.
Register taskq handlers (simple)
This file contains 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
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