-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathoptions.go
More file actions
27 lines (22 loc) · 794 Bytes
/
options.go
File metadata and controls
27 lines (22 loc) · 794 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
package finish
import "time"
// An Option can be used to change the behavior when registering a server via [Finisher.Add].
type Option option
type option func(keeper *serverKeeper) error
// WithTimeout overrides the global [Finisher].Timeout for the server to be registered via [Finisher.Add].
func WithTimeout(timeout time.Duration) Option {
return func(keeper *serverKeeper) error {
keeper.timeout = timeout
return nil
}
}
// WithName sets a custom name for the server to be registered via [Finisher.Add].
//
// If there will be only one server registered, the name defaults to “server”.
// Otherwise, the names of the servers default to “server #<num>”.
func WithName(name string) Option {
return func(keeper *serverKeeper) error {
keeper.name = name
return nil
}
}