Skip to content

Commit

Permalink
TWEAK: panic if you supply a nil redis.pool
Browse files Browse the repository at this point in the history
Because that's never going to work and indicates broken source code.
  • Loading branch information
cypriss committed Jul 25, 2016
1 parent 2322042 commit adc78a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions enqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type Enqueuer struct {

// NewEnqueuer creates a new enqueuer with the specified Redis namespace and Redis pool.
func NewEnqueuer(namespace string, pool *redis.Pool) *Enqueuer {
if pool == nil {
panic("NewEnqueuer needs a non-nil *redis.Pool")
}

return &Enqueuer{
Namespace: namespace,
Pool: pool,
Expand Down
4 changes: 4 additions & 0 deletions worker_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ type middlewareHandler struct {

// NewWorkerPool creates a new worker pool. ctx should be a struct literal whose type will be used for middleware and handlers. concurrency specifies how many workers to spin up - each worker can process jobs concurrently.
func NewWorkerPool(ctx interface{}, concurrency uint, namespace string, pool *redis.Pool) *WorkerPool {
if pool == nil {
panic("NewWorkerPool needs a non-nil *redis.Pool")
}

ctxType := reflect.TypeOf(ctx)
validateContextType(ctxType)
wp := &WorkerPool{
Expand Down

0 comments on commit adc78a0

Please sign in to comment.