Skip to content

Commit

Permalink
move check for funcs to StartWorker so that they are not checked for …
Browse files Browse the repository at this point in the history
…IE api starters/stoppers
  • Loading branch information
Jeffrey Koehler committed Oct 13, 2024
1 parent ab48514 commit 0126ecf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 0 additions & 13 deletions redisconsistent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"time"

"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"

"github.com/streemtech/divider"
Expand Down Expand Up @@ -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 &dividerWorker{
conf: *conf,
client: client,
Expand Down
11 changes: 11 additions & 0 deletions redisconsistent/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0126ecf

Please sign in to comment.