mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-01-18 18:55:54 +08:00
Update code to use inspeq package
This commit is contained in:
parent
4179d00b7b
commit
0626daab0b
@ -4,6 +4,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/hibiken/asynq/inspeq"
|
||||
)
|
||||
|
||||
// ****************************************************************************
|
||||
@ -39,7 +40,7 @@ type QueueStateSnapshot struct {
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
}
|
||||
|
||||
func toQueueStateSnapshot(s *asynq.QueueStats) *QueueStateSnapshot {
|
||||
func toQueueStateSnapshot(s *inspeq.QueueStats) *QueueStateSnapshot {
|
||||
return &QueueStateSnapshot{
|
||||
Queue: s.Queue,
|
||||
MemoryUsage: s.MemoryUsage,
|
||||
@ -65,7 +66,7 @@ type DailyStats struct {
|
||||
Date string `json:"date"`
|
||||
}
|
||||
|
||||
func toDailyStats(s *asynq.DailyStats) *DailyStats {
|
||||
func toDailyStats(s *inspeq.DailyStats) *DailyStats {
|
||||
return &DailyStats{
|
||||
Queue: s.Queue,
|
||||
Processed: s.Processed,
|
||||
@ -75,7 +76,7 @@ func toDailyStats(s *asynq.DailyStats) *DailyStats {
|
||||
}
|
||||
}
|
||||
|
||||
func toDailyStatsList(in []*asynq.DailyStats) []*DailyStats {
|
||||
func toDailyStatsList(in []*inspeq.DailyStats) []*DailyStats {
|
||||
out := make([]*DailyStats, len(in))
|
||||
for i, s := range in {
|
||||
out[i] = toDailyStats(s)
|
||||
@ -110,7 +111,7 @@ type ActiveTask struct {
|
||||
Deadline string `json:"deadline"`
|
||||
}
|
||||
|
||||
func toActiveTask(t *asynq.ActiveTask) *ActiveTask {
|
||||
func toActiveTask(t *inspeq.ActiveTask) *ActiveTask {
|
||||
base := &BaseTask{
|
||||
ID: t.ID,
|
||||
Type: t.Type,
|
||||
@ -123,7 +124,7 @@ func toActiveTask(t *asynq.ActiveTask) *ActiveTask {
|
||||
return &ActiveTask{BaseTask: base}
|
||||
}
|
||||
|
||||
func toActiveTasks(in []*asynq.ActiveTask) []*ActiveTask {
|
||||
func toActiveTasks(in []*inspeq.ActiveTask) []*ActiveTask {
|
||||
out := make([]*ActiveTask, len(in))
|
||||
for i, t := range in {
|
||||
out[i] = toActiveTask(t)
|
||||
@ -136,7 +137,7 @@ type PendingTask struct {
|
||||
Key string `json:"key"`
|
||||
}
|
||||
|
||||
func toPendingTask(t *asynq.PendingTask) *PendingTask {
|
||||
func toPendingTask(t *inspeq.PendingTask) *PendingTask {
|
||||
base := &BaseTask{
|
||||
ID: t.ID,
|
||||
Type: t.Type,
|
||||
@ -152,7 +153,7 @@ func toPendingTask(t *asynq.PendingTask) *PendingTask {
|
||||
}
|
||||
}
|
||||
|
||||
func toPendingTasks(in []*asynq.PendingTask) []*PendingTask {
|
||||
func toPendingTasks(in []*inspeq.PendingTask) []*PendingTask {
|
||||
out := make([]*PendingTask, len(in))
|
||||
for i, t := range in {
|
||||
out[i] = toPendingTask(t)
|
||||
@ -166,7 +167,7 @@ type ScheduledTask struct {
|
||||
NextProcessAt time.Time `json:"next_process_at"`
|
||||
}
|
||||
|
||||
func toScheduledTask(t *asynq.ScheduledTask) *ScheduledTask {
|
||||
func toScheduledTask(t *inspeq.ScheduledTask) *ScheduledTask {
|
||||
base := &BaseTask{
|
||||
ID: t.ID,
|
||||
Type: t.Type,
|
||||
@ -183,7 +184,7 @@ func toScheduledTask(t *asynq.ScheduledTask) *ScheduledTask {
|
||||
}
|
||||
}
|
||||
|
||||
func toScheduledTasks(in []*asynq.ScheduledTask) []*ScheduledTask {
|
||||
func toScheduledTasks(in []*inspeq.ScheduledTask) []*ScheduledTask {
|
||||
out := make([]*ScheduledTask, len(in))
|
||||
for i, t := range in {
|
||||
out[i] = toScheduledTask(t)
|
||||
@ -197,7 +198,7 @@ type RetryTask struct {
|
||||
NextProcessAt time.Time `json:"next_process_at"`
|
||||
}
|
||||
|
||||
func toRetryTask(t *asynq.RetryTask) *RetryTask {
|
||||
func toRetryTask(t *inspeq.RetryTask) *RetryTask {
|
||||
base := &BaseTask{
|
||||
ID: t.ID,
|
||||
Type: t.Type,
|
||||
@ -214,7 +215,7 @@ func toRetryTask(t *asynq.RetryTask) *RetryTask {
|
||||
}
|
||||
}
|
||||
|
||||
func toRetryTasks(in []*asynq.RetryTask) []*RetryTask {
|
||||
func toRetryTasks(in []*inspeq.RetryTask) []*RetryTask {
|
||||
out := make([]*RetryTask, len(in))
|
||||
for i, t := range in {
|
||||
out[i] = toRetryTask(t)
|
||||
@ -228,7 +229,7 @@ type ArchivedTask struct {
|
||||
LastFailedAt time.Time `json:"last_failed_at"`
|
||||
}
|
||||
|
||||
func toArchivedTask(t *asynq.ArchivedTask) *ArchivedTask {
|
||||
func toArchivedTask(t *inspeq.ArchivedTask) *ArchivedTask {
|
||||
base := &BaseTask{
|
||||
ID: t.ID,
|
||||
Type: t.Type,
|
||||
@ -245,7 +246,7 @@ func toArchivedTask(t *asynq.ArchivedTask) *ArchivedTask {
|
||||
}
|
||||
}
|
||||
|
||||
func toArchivedTasks(in []*asynq.ArchivedTask) []*ArchivedTask {
|
||||
func toArchivedTasks(in []*inspeq.ArchivedTask) []*ArchivedTask {
|
||||
out := make([]*ArchivedTask, len(in))
|
||||
for i, t := range in {
|
||||
out[i] = toArchivedTask(t)
|
||||
@ -264,7 +265,7 @@ type SchedulerEntry struct {
|
||||
PrevEnqueueAt string `json:"prev_enqueue_at,omitempty"`
|
||||
}
|
||||
|
||||
func toSchedulerEntry(e *asynq.SchedulerEntry) *SchedulerEntry {
|
||||
func toSchedulerEntry(e *inspeq.SchedulerEntry) *SchedulerEntry {
|
||||
opts := make([]string, 0) // create a non-nil, empty slice to avoid null in json output
|
||||
for _, o := range e.Opts {
|
||||
opts = append(opts, o.String())
|
||||
@ -284,7 +285,7 @@ func toSchedulerEntry(e *asynq.SchedulerEntry) *SchedulerEntry {
|
||||
}
|
||||
}
|
||||
|
||||
func toSchedulerEntries(in []*asynq.SchedulerEntry) []*SchedulerEntry {
|
||||
func toSchedulerEntries(in []*inspeq.SchedulerEntry) []*SchedulerEntry {
|
||||
out := make([]*SchedulerEntry, len(in))
|
||||
for i, e := range in {
|
||||
out[i] = toSchedulerEntry(e)
|
||||
@ -297,14 +298,14 @@ type SchedulerEnqueueEvent struct {
|
||||
EnqueuedAt string `json:"enqueued_at"`
|
||||
}
|
||||
|
||||
func toSchedulerEnqueueEvent(e *asynq.SchedulerEnqueueEvent) *SchedulerEnqueueEvent {
|
||||
func toSchedulerEnqueueEvent(e *inspeq.SchedulerEnqueueEvent) *SchedulerEnqueueEvent {
|
||||
return &SchedulerEnqueueEvent{
|
||||
TaskID: e.TaskID,
|
||||
EnqueuedAt: e.EnqueuedAt.Format(time.RFC3339),
|
||||
}
|
||||
}
|
||||
|
||||
func toSchedulerEnqueueEvents(in []*asynq.SchedulerEnqueueEvent) []*SchedulerEnqueueEvent {
|
||||
func toSchedulerEnqueueEvents(in []*inspeq.SchedulerEnqueueEvent) []*SchedulerEnqueueEvent {
|
||||
out := make([]*SchedulerEnqueueEvent, len(in))
|
||||
for i, e := range in {
|
||||
out[i] = toSchedulerEnqueueEvent(e)
|
||||
@ -324,7 +325,7 @@ type ServerInfo struct {
|
||||
ActiveWorkers []*WorkerInfo `json:"active_workers"`
|
||||
}
|
||||
|
||||
func toServerInfo(info *asynq.ServerInfo) *ServerInfo {
|
||||
func toServerInfo(info *inspeq.ServerInfo) *ServerInfo {
|
||||
return &ServerInfo{
|
||||
ID: info.ID,
|
||||
Host: info.Host,
|
||||
@ -338,7 +339,7 @@ func toServerInfo(info *asynq.ServerInfo) *ServerInfo {
|
||||
}
|
||||
}
|
||||
|
||||
func toServerInfoList(in []*asynq.ServerInfo) []*ServerInfo {
|
||||
func toServerInfoList(in []*inspeq.ServerInfo) []*ServerInfo {
|
||||
out := make([]*ServerInfo, len(in))
|
||||
for i, s := range in {
|
||||
out[i] = toServerInfo(s)
|
||||
@ -351,14 +352,14 @@ type WorkerInfo struct {
|
||||
Started string `json:"start_time"`
|
||||
}
|
||||
|
||||
func toWorkerInfo(info *asynq.WorkerInfo) *WorkerInfo {
|
||||
func toWorkerInfo(info *inspeq.WorkerInfo) *WorkerInfo {
|
||||
return &WorkerInfo{
|
||||
Task: toActiveTask(info.Task),
|
||||
Started: info.Started.Format(time.RFC3339),
|
||||
}
|
||||
}
|
||||
|
||||
func toWorkerInfoList(in []*asynq.WorkerInfo) []*WorkerInfo {
|
||||
func toWorkerInfoList(in []*inspeq.WorkerInfo) []*WorkerInfo {
|
||||
out := make([]*WorkerInfo, len(in))
|
||||
for i, w := range in {
|
||||
out[i] = toWorkerInfo(w)
|
||||
|
4
go.mod
4
go.mod
@ -9,4 +9,6 @@ require (
|
||||
github.com/rs/cors v1.7.0
|
||||
)
|
||||
|
||||
replace github.com/hibiken/asynq => ../../../database/Redis/go/asynq
|
||||
replace (
|
||||
github.com/hibiken/asynq => ../../../database/Redis/go/asynq
|
||||
)
|
||||
|
3
main.go
3
main.go
@ -15,6 +15,7 @@ import (
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/hibiken/asynq/inspeq"
|
||||
"github.com/rs/cors"
|
||||
)
|
||||
|
||||
@ -95,7 +96,7 @@ func main() {
|
||||
tlsConfig = &tls.Config{ServerName: flagRedisTLS}
|
||||
}
|
||||
|
||||
inspector := asynq.NewInspector(asynq.RedisClientOpt{
|
||||
inspector := inspeq.New(asynq.RedisClientOpt{
|
||||
Addr: flagRedisAddr,
|
||||
DB: flagRedisDB,
|
||||
Password: flagRedisPassword,
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/hibiken/asynq/inspeq"
|
||||
)
|
||||
|
||||
// ****************************************************************************
|
||||
@ -13,7 +13,7 @@ import (
|
||||
// - http.Handler(s) for queue related endpoints
|
||||
// ****************************************************************************
|
||||
|
||||
func newListQueuesHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newListQueuesHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
qnames, err := inspector.Queues()
|
||||
if err != nil {
|
||||
@ -34,7 +34,7 @@ func newListQueuesHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func newGetQueueHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newGetQueueHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
qname := vars["qname"]
|
||||
@ -63,16 +63,16 @@ func newGetQueueHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func newDeleteQueueHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newDeleteQueueHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
qname := vars["qname"]
|
||||
if err := inspector.DeleteQueue(qname, false); err != nil {
|
||||
if _, ok := err.(*asynq.ErrQueueNotFound); ok {
|
||||
if _, ok := err.(*inspeq.ErrQueueNotFound); ok {
|
||||
http.Error(w, err.Error(), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if _, ok := err.(*asynq.ErrQueueNotEmpty); ok {
|
||||
if _, ok := err.(*inspeq.ErrQueueNotEmpty); ok {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
@ -83,7 +83,7 @@ func newDeleteQueueHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func newPauseQueueHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newPauseQueueHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
qname := vars["qname"]
|
||||
@ -95,7 +95,7 @@ func newPauseQueueHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func newResumeQueueHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newResumeQueueHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
qname := vars["qname"]
|
||||
@ -111,7 +111,7 @@ type ListQueueStatsResponse struct {
|
||||
Stats map[string][]*DailyStats `json:"stats"`
|
||||
}
|
||||
|
||||
func newListQueueStatsHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newListQueueStatsHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
qnames, err := inspector.Queues()
|
||||
if err != nil {
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/hibiken/asynq/inspeq"
|
||||
)
|
||||
|
||||
// ****************************************************************************
|
||||
@ -13,7 +13,7 @@ import (
|
||||
// - http.Handler(s) for scheduler entry related endpoints
|
||||
// ****************************************************************************
|
||||
|
||||
func newListSchedulerEntriesHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newListSchedulerEntriesHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
entries, err := inspector.SchedulerEntries()
|
||||
if err != nil {
|
||||
@ -38,12 +38,12 @@ type ListSchedulerEnqueueEventsResponse struct {
|
||||
Events []*SchedulerEnqueueEvent `json:"events"`
|
||||
}
|
||||
|
||||
func newListSchedulerEnqueueEventsHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newListSchedulerEnqueueEventsHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
entryID := mux.Vars(r)["entry_id"]
|
||||
pageSize, pageNum := getPageOptions(r)
|
||||
events, err := inspector.ListSchedulerEnqueueEvents(
|
||||
entryID, asynq.PageSize(pageSize), asynq.Page(pageNum))
|
||||
entryID, inspeq.PageSize(pageSize), inspeq.Page(pageNum))
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/hibiken/asynq/inspeq"
|
||||
)
|
||||
|
||||
// ****************************************************************************
|
||||
@ -16,7 +16,7 @@ type ListServersResponse struct {
|
||||
Servers []*ServerInfo `json:"servers"`
|
||||
}
|
||||
|
||||
func newListServersHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newListServersHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
srvs, err := inspector.Servers()
|
||||
if err != nil {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/hibiken/asynq/inspeq"
|
||||
)
|
||||
|
||||
// ****************************************************************************
|
||||
@ -21,14 +21,14 @@ type ListActiveTasksResponse struct {
|
||||
Stats *QueueStateSnapshot `json:"stats"`
|
||||
}
|
||||
|
||||
func newListActiveTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newListActiveTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
qname := vars["qname"]
|
||||
pageSize, pageNum := getPageOptions(r)
|
||||
|
||||
tasks, err := inspector.ListActiveTasks(
|
||||
qname, asynq.PageSize(pageSize), asynq.Page(pageNum))
|
||||
qname, inspeq.PageSize(pageSize), inspeq.Page(pageNum))
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@ -44,7 +44,7 @@ func newListActiveTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc
|
||||
return
|
||||
}
|
||||
// m maps taskID to WorkerInfo.
|
||||
m := make(map[string]*asynq.WorkerInfo)
|
||||
m := make(map[string]*inspeq.WorkerInfo)
|
||||
for _, srv := range servers {
|
||||
for _, w := range srv.ActiveWorkers {
|
||||
if w.Task.Queue == qname {
|
||||
@ -75,7 +75,7 @@ func newListActiveTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc
|
||||
}
|
||||
}
|
||||
|
||||
func newCancelActiveTaskHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newCancelActiveTaskHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
id := mux.Vars(r)["task_id"]
|
||||
if err := inspector.CancelActiveTask(id); err != nil {
|
||||
@ -86,13 +86,13 @@ func newCancelActiveTaskHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc
|
||||
}
|
||||
}
|
||||
|
||||
func newCancelAllActiveTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newCancelAllActiveTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
const batchSize = 100
|
||||
page := 1
|
||||
qname := mux.Vars(r)["qname"]
|
||||
for {
|
||||
tasks, err := inspector.ListActiveTasks(qname, asynq.Page(page), asynq.PageSize(batchSize))
|
||||
tasks, err := inspector.ListActiveTasks(qname, inspeq.Page(page), inspeq.PageSize(batchSize))
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@ -121,7 +121,7 @@ type batchCancelTasksResponse struct {
|
||||
ErrorIDs []string `json:"error_ids"`
|
||||
}
|
||||
|
||||
func newBatchCancelActiveTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newBatchCancelActiveTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Body = http.MaxBytesReader(w, r.Body, maxRequestBodySize)
|
||||
dec := json.NewDecoder(r.Body)
|
||||
@ -153,13 +153,13 @@ func newBatchCancelActiveTasksHandlerFunc(inspector *asynq.Inspector) http.Handl
|
||||
}
|
||||
}
|
||||
|
||||
func newListPendingTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newListPendingTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
qname := vars["qname"]
|
||||
pageSize, pageNum := getPageOptions(r)
|
||||
tasks, err := inspector.ListPendingTasks(
|
||||
qname, asynq.PageSize(pageSize), asynq.Page(pageNum))
|
||||
qname, inspeq.PageSize(pageSize), inspeq.Page(pageNum))
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@ -184,13 +184,13 @@ func newListPendingTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc
|
||||
}
|
||||
}
|
||||
|
||||
func newListScheduledTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newListScheduledTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
qname := vars["qname"]
|
||||
pageSize, pageNum := getPageOptions(r)
|
||||
tasks, err := inspector.ListScheduledTasks(
|
||||
qname, asynq.PageSize(pageSize), asynq.Page(pageNum))
|
||||
qname, inspeq.PageSize(pageSize), inspeq.Page(pageNum))
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@ -215,13 +215,13 @@ func newListScheduledTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFu
|
||||
}
|
||||
}
|
||||
|
||||
func newListRetryTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newListRetryTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
qname := vars["qname"]
|
||||
pageSize, pageNum := getPageOptions(r)
|
||||
tasks, err := inspector.ListRetryTasks(
|
||||
qname, asynq.PageSize(pageSize), asynq.Page(pageNum))
|
||||
qname, inspeq.PageSize(pageSize), inspeq.Page(pageNum))
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@ -246,13 +246,13 @@ func newListRetryTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func newListArchivedTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newListArchivedTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
qname := vars["qname"]
|
||||
pageSize, pageNum := getPageOptions(r)
|
||||
tasks, err := inspector.ListArchivedTasks(
|
||||
qname, asynq.PageSize(pageSize), asynq.Page(pageNum))
|
||||
qname, inspeq.PageSize(pageSize), inspeq.Page(pageNum))
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@ -277,7 +277,7 @@ func newListArchivedTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFun
|
||||
}
|
||||
}
|
||||
|
||||
func newDeleteTaskHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newDeleteTaskHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
qname, key := vars["qname"], vars["task_key"]
|
||||
@ -294,7 +294,7 @@ func newDeleteTaskHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func newRunTaskHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newRunTaskHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
qname, key := vars["qname"], vars["task_key"]
|
||||
@ -311,7 +311,7 @@ func newRunTaskHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func newArchiveTaskHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newArchiveTaskHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
qname, key := vars["qname"], vars["task_key"]
|
||||
@ -333,7 +333,7 @@ type DeleteAllTasksResponse struct {
|
||||
Deleted int `json:"deleted"`
|
||||
}
|
||||
|
||||
func newDeleteAllPendingTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newDeleteAllPendingTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
qname := mux.Vars(r)["qname"]
|
||||
n, err := inspector.DeleteAllPendingTasks(qname)
|
||||
@ -349,7 +349,7 @@ func newDeleteAllPendingTasksHandlerFunc(inspector *asynq.Inspector) http.Handle
|
||||
}
|
||||
}
|
||||
|
||||
func newDeleteAllScheduledTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newDeleteAllScheduledTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
qname := mux.Vars(r)["qname"]
|
||||
n, err := inspector.DeleteAllScheduledTasks(qname)
|
||||
@ -365,7 +365,7 @@ func newDeleteAllScheduledTasksHandlerFunc(inspector *asynq.Inspector) http.Hand
|
||||
}
|
||||
}
|
||||
|
||||
func newDeleteAllRetryTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newDeleteAllRetryTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
qname := mux.Vars(r)["qname"]
|
||||
n, err := inspector.DeleteAllRetryTasks(qname)
|
||||
@ -381,7 +381,7 @@ func newDeleteAllRetryTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerF
|
||||
}
|
||||
}
|
||||
|
||||
func newDeleteAllArchivedTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newDeleteAllArchivedTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
qname := mux.Vars(r)["qname"]
|
||||
n, err := inspector.DeleteAllArchivedTasks(qname)
|
||||
@ -397,7 +397,7 @@ func newDeleteAllArchivedTasksHandlerFunc(inspector *asynq.Inspector) http.Handl
|
||||
}
|
||||
}
|
||||
|
||||
func newRunAllScheduledTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newRunAllScheduledTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
qname := mux.Vars(r)["qname"]
|
||||
if _, err := inspector.RunAllScheduledTasks(qname); err != nil {
|
||||
@ -408,7 +408,7 @@ func newRunAllScheduledTasksHandlerFunc(inspector *asynq.Inspector) http.Handler
|
||||
}
|
||||
}
|
||||
|
||||
func newRunAllRetryTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newRunAllRetryTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
qname := mux.Vars(r)["qname"]
|
||||
if _, err := inspector.RunAllRetryTasks(qname); err != nil {
|
||||
@ -419,7 +419,7 @@ func newRunAllRetryTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc
|
||||
}
|
||||
}
|
||||
|
||||
func newRunAllArchivedTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newRunAllArchivedTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
qname := mux.Vars(r)["qname"]
|
||||
if _, err := inspector.RunAllArchivedTasks(qname); err != nil {
|
||||
@ -430,7 +430,7 @@ func newRunAllArchivedTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerF
|
||||
}
|
||||
}
|
||||
|
||||
func newArchiveAllPendingTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newArchiveAllPendingTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
qname := mux.Vars(r)["qname"]
|
||||
if _, err := inspector.ArchiveAllPendingTasks(qname); err != nil {
|
||||
@ -441,7 +441,7 @@ func newArchiveAllPendingTasksHandlerFunc(inspector *asynq.Inspector) http.Handl
|
||||
}
|
||||
}
|
||||
|
||||
func newArchiveAllScheduledTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newArchiveAllScheduledTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
qname := mux.Vars(r)["qname"]
|
||||
if _, err := inspector.ArchiveAllScheduledTasks(qname); err != nil {
|
||||
@ -452,7 +452,7 @@ func newArchiveAllScheduledTasksHandlerFunc(inspector *asynq.Inspector) http.Han
|
||||
}
|
||||
}
|
||||
|
||||
func newArchiveAllRetryTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newArchiveAllRetryTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
qname := mux.Vars(r)["qname"]
|
||||
if _, err := inspector.ArchiveAllRetryTasks(qname); err != nil {
|
||||
@ -484,7 +484,7 @@ type batchDeleteTasksResponse struct {
|
||||
// Allow up to 1MB in size.
|
||||
const maxRequestBodySize = 1000000
|
||||
|
||||
func newBatchDeleteTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newBatchDeleteTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Body = http.MaxBytesReader(w, r.Body, maxRequestBodySize)
|
||||
dec := json.NewDecoder(r.Body)
|
||||
@ -528,7 +528,7 @@ type batchRunTasksResponse struct {
|
||||
ErrorKeys []string `json:"error_keys"`
|
||||
}
|
||||
|
||||
func newBatchRunTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newBatchRunTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Body = http.MaxBytesReader(w, r.Body, maxRequestBodySize)
|
||||
dec := json.NewDecoder(r.Body)
|
||||
@ -572,7 +572,7 @@ type batchArchiveTasksResponse struct {
|
||||
ErrorKeys []string `json:"error_keys"`
|
||||
}
|
||||
|
||||
func newBatchArchiveTasksHandlerFunc(inspector *asynq.Inspector) http.HandlerFunc {
|
||||
func newBatchArchiveTasksHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Body = http.MaxBytesReader(w, r.Body, maxRequestBodySize)
|
||||
dec := json.NewDecoder(r.Body)
|
||||
|
Loading…
Reference in New Issue
Block a user