chore(queue): upgrade queue package and add metrics (#673)
* chore(queue): upgrade queue package and add metrics add new metrics BusyWorkers *prometheus.Desc SuccessTasks *prometheus.Desc FailureTasks *prometheus.Desc SubmittedTasks *prometheus.Desc fix https://github.com/appleboy/gorush/issues/672 Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * chore: update go version Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@@ -121,8 +121,10 @@ func appStatusHandler(q *queue.Queue) gin.HandlerFunc {
|
||||
result := status.App{}
|
||||
|
||||
result.Version = GetVersion()
|
||||
result.QueueMax = q.Capacity()
|
||||
result.QueueUsage = q.Usage()
|
||||
result.BusyWorkers = q.BusyWorkers()
|
||||
result.SuccessTasks = q.SuccessTasks()
|
||||
result.FailureTasks = q.FailureTasks()
|
||||
result.SubmittedTasks = q.SubmittedTasks()
|
||||
result.TotalCount = status.StatStorage.GetTotalCount()
|
||||
result.Ios.PushSuccess = status.StatStorage.GetIosSuccess()
|
||||
result.Ios.PushError = status.StatStorage.GetIosError()
|
||||
@@ -184,9 +186,7 @@ func routerEngine(cfg *config.ConfYaml, q *queue.Queue) *gin.Engine {
|
||||
|
||||
// Support metrics
|
||||
doOnce.Do(func() {
|
||||
m := metric.NewMetrics(func() int {
|
||||
return q.Usage()
|
||||
})
|
||||
m := metric.NewMetrics(q)
|
||||
prometheus.MustRegister(m)
|
||||
})
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/buger/jsonparser"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang-queue/queue"
|
||||
qcore "github.com/golang-queue/queue/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -44,7 +45,7 @@ func TestMain(m *testing.M) {
|
||||
|
||||
q = queue.NewPool(
|
||||
int(cfg.Core.WorkerNum),
|
||||
queue.WithFn(func(ctx context.Context, msg queue.QueuedMessage) error {
|
||||
queue.WithFn(func(ctx context.Context, msg qcore.QueuedMessage) error {
|
||||
_, err := notify.SendNotification(msg, cfg)
|
||||
return err
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user