-
Notifications
You must be signed in to change notification settings - Fork 0
/
dependency_option.go
30 lines (25 loc) · 1019 Bytes
/
dependency_option.go
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
package otfranz
// Interceptor is an interceptor that makes last minute change to a *Config
// during kgo.Client's creation
type Interceptor func(name string, config *Config)
type providersOption struct {
reloadable bool
interceptor Interceptor
}
// ProvidersOptionFunc is the type of functional providersOption for Providers. Use this type to change how Providers work.
type ProvidersOptionFunc func(options *providersOption)
// WithInterceptor instructs the Providers to accept the
// Interceptor so that users can change config during runtime. This can
// be useful when some dynamic computations on configs are required.
func WithInterceptor(interceptor Interceptor) ProvidersOptionFunc {
return func(options *providersOption) {
options.interceptor = interceptor
}
}
// WithReload toggles whether the factory should reload cached instances upon
// OnReload event.
func WithReload(shouldReload bool) ProvidersOptionFunc {
return func(options *providersOption) {
options.reloadable = shouldReload
}
}