Skip to content

Commit

Permalink
upd test
Browse files Browse the repository at this point in the history
  • Loading branch information
peakle committed Aug 7, 2023
1 parent bcf0b5e commit eecc260
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type config struct {
KeepAliveTimeout time.Duration
TimeoutJitter int64 // additional random timeout in ms
GracefulTimeout time.Duration
TaskChLen int
}

type logger interface {
Expand Down Expand Up @@ -64,3 +65,13 @@ func WithGracefulTimeout(t time.Duration) Option {
func (t gracefulTimeout) apply(cfg *config) {
cfg.GracefulTimeout = time.Duration(t)
}

type taskChLen int

func WithTaskLen(t int) Option {
return taskChLen(t)
}

func (t taskChLen) apply(cfg *config) {
cfg.TaskChLen = int(t)
}
2 changes: 2 additions & 0 deletions pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func TestOnPanic(t *testing.T) {
context.Background(),
WithJitter(1),
WithCapacity(testCount),
WithTaskLen(0),
)
pool.SetLogger(log.New(io.Discard, "", 0))

Expand Down Expand Up @@ -217,6 +218,7 @@ func TestCloseGracefullyByTimeout(t *testing.T) {
WithKeepAlive(time.Minute),
WithCapacity(1),
WithGracefulTimeout(3*time.Second),
WithTaskLen(2),
)

task := func(ctx context.Context) {
Expand Down

0 comments on commit eecc260

Please sign in to comment.