-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgroup_options.go
More file actions
33 lines (27 loc) · 871 Bytes
/
Copy pathgroup_options.go
File metadata and controls
33 lines (27 loc) · 871 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
package coda
import "time"
type groupOptions struct {
shutdownTimeout time.Duration
}
func defaultGroupOptions() *groupOptions {
return &groupOptions{
shutdownTimeout: -1, // Default is no shutdown timeout
}
}
type GroupOption func(*groupOptions)
func buildGroupOptions(opts ...GroupOption) *groupOptions {
options := defaultGroupOptions()
for _, fn := range opts {
fn(options)
}
return options
}
// WithGroupShutdownTimeout sets the time the shutdown Group will wait for a goroutine to exit when the shutdown signal
// is sent. Any value less than 0 will disable the timeout and will cause the shutdown manager to wait indefinitely.
// Default is no timeout (-1).
// It can be passed to the Shutdown.NewGroup function.
func WithGroupShutdownTimeout(d time.Duration) GroupOption {
return func(options *groupOptions) {
options.shutdownTimeout = d
}
}