asynqmon/example_test.go

31 lines
506 B
Go
Raw Normal View History

2021-10-03 10:04:21 +08:00
package asynqmon_test
import (
"log"
"net/http"
2021-10-05 14:09:11 +08:00
"github.com/gorilla/mux"
2021-10-03 10:04:21 +08:00
"github.com/hibiken/asynq"
"github.com/hibiken/asynqmon"
)
2021-10-04 23:18:00 +08:00
func ExampleNew() {
h := asynqmon.New(asynqmon.Options{
2021-10-03 10:04:21 +08:00
RedisConnOpt: asynq.RedisClientOpt{Addr: ":6379"},
})
2021-10-04 23:18:00 +08:00
defer h.Close()
2021-10-03 10:04:21 +08:00
2021-10-05 14:09:11 +08:00
r := mux.NewRouter()
r.PathPrefix("/api").Handler(h)
// Add static content handler or other handlers
// r.PathPrefix("/").Handler(h)
2021-10-03 10:04:21 +08:00
srv := &http.Server{
2021-10-05 14:09:11 +08:00
Handler: r,
2021-10-03 10:04:21 +08:00
Addr: ":8080",
}
log.Fatal(srv.ListenAndServe())
}