From 0126ecf50670eaf6b70ee516aae361765b8e2380 Mon Sep 17 00:00:00 2001 From: Jeffrey Koehler Date: Sun, 13 Oct 2024 00:46:45 -0500 Subject: [PATCH] move check for funcs to StartWorker so that they are not checked for IE api starters/stoppers --- redisconsistent/config.go | 13 ------------- redisconsistent/redis.go | 11 +++++++++++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/redisconsistent/config.go b/redisconsistent/config.go index fc3c208..b79286c 100644 --- a/redisconsistent/config.go +++ b/redisconsistent/config.go @@ -4,7 +4,6 @@ import ( "time" "github.com/google/uuid" - "github.com/pkg/errors" "github.com/redis/go-redis/v9" "github.com/streemtech/divider" @@ -152,18 +151,6 @@ func New(client redis.UniversalClient, rootKey string, Opts ...DividerOpt) (divi v(conf) } - if conf.starter == nil { - return nil, errors.New("missing starter func") - } - - if conf.stopper == nil { - return nil, errors.New("missing stopper func") - } - - if conf.workFetcher == nil { - return nil, errors.New("missing work fetcher func") - } - return ÷rWorker{ conf: *conf, client: client, diff --git a/redisconsistent/redis.go b/redisconsistent/redis.go index a2a2331..e44153d 100644 --- a/redisconsistent/redis.go +++ b/redisconsistent/redis.go @@ -24,6 +24,17 @@ func (d *dividerWorker) StartWorker(ctx context.Context) { return } + //can not start worker if expected functions are nil. + if d.conf.starter == nil { + panic("missing starter func") + } + if d.conf.stopper == nil { + panic("missing stopper func") + } + if d.conf.workFetcher == nil { + panic("missing work fetcher func") + } + d.ctx, d.cancel = context.WithCancel(context.WithoutCancel(ctx)) var logger divider.LoggerGen