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