forked from wellle/rmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
34 lines (27 loc) · 828 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"fmt"
"log"
"net/http"
"github.com/adjust/rmq"
)
func main() {
connection := rmq.OpenConnection("handler", "tcp", "localhost:6379", 2)
http.Handle("/overview", NewHandler(connection))
fmt.Printf("Handler listening on http://localhost:3333/overview\n")
http.ListenAndServe(":3333", nil)
}
type Handler struct {
connection rmq.Connection
}
func NewHandler(connection rmq.Connection) *Handler {
return &Handler{connection: connection}
}
func (handler *Handler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
layout := request.FormValue("layout")
refresh := request.FormValue("refresh")
queues := handler.connection.GetOpenQueues()
stats := handler.connection.CollectStats(queues)
log.Printf("queue stats\n%s", stats)
fmt.Fprint(writer, stats.GetHtml(layout, refresh))
}