Created
July 22, 2015 00:56
-
-
Save soheilhy/654d826452066e022994 to your computer and use it in GitHub Desktop.
Register HTTP Handlers
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
// 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, | |
}) | |
ah := &AckHTTPHandler{Hive: h} | |
a.HandleHTTP("/{queue}/tasks/{id:[0-9]+}", ah).Methods("DELETE") | |
dh := &DeQHTTPHandler{Hive: h} | |
a.HandleHTTP("/{queue}/tasks/deque", dh).Methods("POST") | |
eh := &EnQHTTPHandler{Hive: h} | |
a.HandleHTTP("/{queue}/tasks", eh).Methods("POST") | |
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