Add API endpoint to fetch redis info

This commit is contained in:
Ken Hibino
2021-01-03 06:56:53 -08:00
parent 9ac455cc7b
commit 094e23f736
4 changed files with 57 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import (
"path/filepath"
"time"
"github.com/go-redis/redis/v8"
"github.com/gorilla/mux"
"github.com/hibiken/asynq"
"github.com/rs/cors"
@@ -64,6 +65,11 @@ func main() {
})
defer inspector.Close()
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
})
defer rdb.Close()
router := mux.NewRouter()
router.Use(loggingMiddleware)
@@ -119,6 +125,9 @@ func main() {
api.HandleFunc("/scheduler_entries", newListSchedulerEntriesHandlerFunc(inspector)).Methods("GET")
api.HandleFunc("/scheduler_entries/{entry_id}/enqueue_events", newListSchedulerEnqueueEventsHandlerFunc(inspector)).Methods("GET")
// Redis info endpoint.
api.HandleFunc("/redis_info", newRedisInfoHandlerFunc(rdb)).Methods("GET")
fs := &staticFileServer{staticPath: "ui/build", indexPath: "index.html"}
router.PathPrefix("/").Handler(fs)