From a9a8b775f505a232c6c3fab6d95ab98ae37a7f6d Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 24 Apr 2024 21:10:28 +0200 Subject: [PATCH] Update kit version --- cmd/worker/worker.go | 27 ++++++++++++++------------- go.mod | 2 +- go.sum | 4 ++-- pkg/example/creator.go | 3 ++- pkg/example/tasks.go | 7 +------ 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/cmd/worker/worker.go b/cmd/worker/worker.go index 9c6eb42..12cbbbf 100644 --- a/cmd/worker/worker.go +++ b/cmd/worker/worker.go @@ -103,19 +103,20 @@ func NewWorker(ctx context.Context, config config.Config) (*Worker, error) { } worker := kit.NewWorker(observer, errorHandler, kit.WorkerConfig{ - Queues: config.Worker.Queues, - Concurrency: kitUtil.Pointer(config.Worker.Concurrency), - StrictPriority: kitUtil.Pointer(config.Worker.StrictPriority), - StopTimeout: kitUtil.Pointer(config.Worker.StopTimeout), - TimeZone: kitUtil.Pointer(config.Service.TimeZone), - CacheHost: config.Cache.Host, - CachePort: config.Cache.Port, - CacheSSLMode: config.Cache.SSLMode, - CachePassword: config.Cache.Password, - CacheMaxConns: kitUtil.Pointer(config.Cache.MaxConns), - CacheReadTimeout: kitUtil.Pointer(config.Cache.ReadTimeout), - CacheWriteTimeout: kitUtil.Pointer(config.Cache.WriteTimeout), - CacheDialTimeout: kitUtil.Pointer(config.Cache.DialTimeout), + Queues: config.Worker.Queues, + Concurrency: kitUtil.Pointer(config.Worker.Concurrency), + StrictPriority: kitUtil.Pointer(config.Worker.StrictPriority), + StopTimeout: kitUtil.Pointer(config.Worker.StopTimeout), + TimeZone: kitUtil.Pointer(config.Service.TimeZone), + ScheduleDefaultRetry: kitUtil.Pointer(0), + CacheHost: config.Cache.Host, + CachePort: config.Cache.Port, + CacheSSLMode: config.Cache.SSLMode, + CachePassword: config.Cache.Password, + CacheMaxConns: kitUtil.Pointer(config.Cache.MaxConns), + CacheReadTimeout: kitUtil.Pointer(config.Cache.ReadTimeout), + CacheWriteTimeout: kitUtil.Pointer(config.Cache.WriteTimeout), + CacheDialTimeout: kitUtil.Pointer(config.Cache.DialTimeout), }) observerMiddleware := kitMiddleware.NewObserver(observer, kitMiddleware.ObserverConfig{}) diff --git a/go.mod b/go.mod index abf5b3d..e4e03f1 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/leporo/sqlf v1.4.0 github.com/mkideal/cli v0.2.7 github.com/neoxelox/errors v0.2.0 - github.com/neoxelox/kit v0.33.0 + github.com/neoxelox/kit v0.34.0 github.com/rs/xid v1.5.0 golang.org/x/text v0.14.0 ) diff --git a/go.sum b/go.sum index 903f309..b005719 100644 --- a/go.sum +++ b/go.sum @@ -221,8 +221,8 @@ github.com/neoxelox/errors v0.2.0 h1:AhvCMJAjUBFCP3PgZHbY6SS8Sc9fxx/DiawU5Cd5RxE github.com/neoxelox/errors v0.2.0/go.mod h1:gCPnC7z8Qwswwz5Usv3WORxvan9Q6WSrDTvzaQyl7oM= github.com/neoxelox/gilk v0.5.0 h1:Knw/TgSUnwPDIRJbqoTmG98gYsmKojNCJ5WAjALoWFc= github.com/neoxelox/gilk v0.5.0/go.mod h1:Q+WgmSMKWd5UAaVjLSmGPbVD11AmHFhlo3QrPum0vo0= -github.com/neoxelox/kit v0.33.0 h1:9IlIuwVP3Bb+herHpDTLYEA9vFUKGCD1C67LD2hr3U8= -github.com/neoxelox/kit v0.33.0/go.mod h1:IgYpZ0XID15bSpHXCnrJA6to5j69fzkbn0knfsEpdAE= +github.com/neoxelox/kit v0.34.0 h1:cO3o17Xwr5dVVKrqoMO/t1J2okJ0WCzuZyA58jgbPSM= +github.com/neoxelox/kit v0.34.0/go.mod h1:IgYpZ0XID15bSpHXCnrJA6to5j69fzkbn0knfsEpdAE= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= diff --git a/pkg/example/creator.go b/pkg/example/creator.go index d982d0b..3009847 100644 --- a/pkg/example/creator.go +++ b/pkg/example/creator.go @@ -3,6 +3,7 @@ package example import ( "context" + "github.com/hibiken/asynq" "github.com/neoxelox/errors" "github.com/neoxelox/kit" "github.com/rs/xid" @@ -75,7 +76,7 @@ func (self *ExampleCreator) Create(ctx context.Context, params ExampleCreatorCre err = self.enqueuer.Enqueue(ctx, ExampleTasksMakeOnboarding, ExampleTasksMakeOnboardingParams{ ID: example.ID, - }) + }, asynq.MaxRetry(3)) if err != nil { self.observer.Error(ctx, err) } diff --git a/pkg/example/tasks.go b/pkg/example/tasks.go index 500faf1..c69a076 100644 --- a/pkg/example/tasks.go +++ b/pkg/example/tasks.go @@ -5,7 +5,6 @@ import ( "encoding/json" "github.com/hibiken/asynq" - "github.com/neoxelox/errors" "github.com/neoxelox/kit" "service/pkg/config" @@ -16,10 +15,6 @@ const ( ExampleTasksReconcile = "example:reconcile" ) -var ( - ErrExampleTasksGeneric = errors.New("example task failed") -) - type ExampleTasks struct { config config.Config observer *kit.Observer @@ -50,7 +45,7 @@ func (self *ExampleTasks) MakeOnboarding(ctx context.Context, task *asynq.Task) example, err := self.exampleRepository.Get(ctx, params.ID) if err != nil { - return ErrExampleTasksGeneric.Raise().Cause(err) + return err } if example == nil {