Skip to content

Commit

Permalink
fix: don't force serial job execution on single-CPU systems
Browse files Browse the repository at this point in the history
  • Loading branch information
acaloiaro committed Dec 22, 2024
1 parent dbe8589 commit ef93e68
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

const (
DefaultHandlerTimeout = 30 * time.Second
DefaultConcurrency = 50 // goroutines available to do work
)

var (
Expand Down Expand Up @@ -64,7 +65,8 @@ func JobTimeout(d time.Duration) Option {
}

// Concurrency configures Neoq handlers to process jobs concurrently
// the default concurrency is the number of (v)CPUs on the machine running Neoq
//
// Default concurrency is defined by [DefaultConcurency]
func Concurrency(c int) Option {
return func(h *Handler) {
h.Concurrency = c
Expand Down Expand Up @@ -103,9 +105,8 @@ func New(queue string, f Func, opts ...Option) (h Handler) {

h.WithOptions(opts...)

// default to running on as many goroutines as there are CPUs
if h.Concurrency == 0 {
Concurrency(runtime.NumCPU())(&h)
Concurrency(DefaultConcurrency)(&h)
}

// always set a job timeout if none is set
Expand Down

0 comments on commit ef93e68

Please sign in to comment.