-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
41 lines (33 loc) · 777 Bytes
/
config.go
File metadata and controls
41 lines (33 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package poolerchan
import (
"log/slog"
"os"
)
type Config struct {
numberOfJobs int
numberOfWorkers int
logger *slog.Logger
}
type ConfigOption func(*Config)
func defaultConfigPoolchan() *Config {
return &Config{
numberOfJobs: defaultNumberOfJobs,
numberOfWorkers: defaultNumberOfWorkers,
logger: slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo})),
}
}
func WithNumberOfJobs(nJobs int) ConfigOption {
return func(config *Config) {
config.numberOfJobs = nJobs
}
}
func WithNumberOfWorkers(nWorkers int) ConfigOption {
return func(config *Config) {
config.numberOfWorkers = nWorkers
}
}
func WithLogger(logger *slog.Logger) ConfigOption {
return func(config *Config) {
config.logger = logger
}
}