-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdependency_options.go
36 lines (30 loc) · 1.12 KB
/
dependency_options.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
31
32
33
34
35
36
package queue
import (
"github.com/DoNewsCode/core/contract"
)
type providersOption struct {
driver Driver
driverConstructor func(args DriverArgs) (Driver, error)
}
// ProvidersOptionFunc is the type of functional providersOption for Providers. Use this type to change how Providers work.
type ProvidersOptionFunc func(options *providersOption)
// WithDriver instructs the Providers to accept a queue driver
// different from the default one. This option supersedes the
// WithDriverConstructor option.
func WithDriver(driver Driver) ProvidersOptionFunc {
return func(options *providersOption) {
options.driver = driver
}
}
// WithDriverConstructor instructs the Providers to accept an alternative constructor for queue driver.
// If the WithDriver option is set, this option becomes an no-op.
func WithDriverConstructor(f func(args DriverArgs) (Driver, error)) ProvidersOptionFunc {
return func(options *providersOption) {
options.driverConstructor = f
}
}
// DriverArgs are arguments to construct the driver. See WithDriverConstructor.
type DriverArgs struct {
Name string
Populator contract.DIPopulator
}