-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
options.go
102 lines (89 loc) · 3.3 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package runtime
import (
bindingsLoader "github.com/dapr/dapr/pkg/components/bindings"
configurationLoader "github.com/dapr/dapr/pkg/components/configuration"
lockLoader "github.com/dapr/dapr/pkg/components/lock"
httpMiddlewareLoader "github.com/dapr/dapr/pkg/components/middleware/http"
nrLoader "github.com/dapr/dapr/pkg/components/nameresolution"
pubsubLoader "github.com/dapr/dapr/pkg/components/pubsub"
secretstoresLoader "github.com/dapr/dapr/pkg/components/secretstores"
stateLoader "github.com/dapr/dapr/pkg/components/state"
workflowsLoader "github.com/dapr/dapr/pkg/components/workflows"
)
type (
// runtimeOpts encapsulates the components to include in the runtime.
runtimeOpts struct {
secretStoreRegistry *secretstoresLoader.Registry
stateRegistry *stateLoader.Registry
configurationRegistry *configurationLoader.Registry
lockRegistry *lockLoader.Registry
pubsubRegistry *pubsubLoader.Registry
nameResolutionRegistry *nrLoader.Registry
bindingRegistry *bindingsLoader.Registry
httpMiddlewareRegistry *httpMiddlewareLoader.Registry
workflowComponentRegistry *workflowsLoader.Registry
componentsCallback ComponentsCallback
}
// Option is a function that customizes the runtime.
Option func(o *runtimeOpts)
)
// WithSecretStores adds secret store components to the runtime.
func WithSecretStores(registry *secretstoresLoader.Registry) Option {
return func(o *runtimeOpts) {
o.secretStoreRegistry = registry
}
}
// WithStates adds state store components to the runtime.
func WithStates(registry *stateLoader.Registry) Option {
return func(o *runtimeOpts) {
o.stateRegistry = registry
}
}
// WithConfigurations adds configuration store components to the runtime.
func WithConfigurations(registry *configurationLoader.Registry) Option {
return func(o *runtimeOpts) {
o.configurationRegistry = registry
}
}
// WithLocks add lock store components to the runtime.
func WithLocks(registry *lockLoader.Registry) Option {
return func(o *runtimeOpts) {
o.lockRegistry = registry
}
}
// WithPubSubs adds pubsub store components to the runtime.
func WithPubSubs(registry *pubsubLoader.Registry) Option {
return func(o *runtimeOpts) {
o.pubsubRegistry = registry
}
}
// WithNameResolutions adds name resolution components to the runtime.
func WithNameResolutions(registry *nrLoader.Registry) Option {
return func(o *runtimeOpts) {
o.nameResolutionRegistry = registry
}
}
// WithBindings adds binding components to the runtime.
func WithBindings(registry *bindingsLoader.Registry) Option {
return func(o *runtimeOpts) {
o.bindingRegistry = registry
}
}
// WithHTTPMiddlewares adds HTTP middleware components to the runtime.
func WithHTTPMiddlewares(registry *httpMiddlewareLoader.Registry) Option {
return func(o *runtimeOpts) {
o.httpMiddlewareRegistry = registry
}
}
// WithWorkflowComponents adds workflow components to the runtime.
func WithWorkflowComponents(registry *workflowsLoader.Registry) Option {
return func(o *runtimeOpts) {
o.workflowComponentRegistry = registry
}
}
// WithComponentsCallback sets the components callback for applications that embed Dapr.
func WithComponentsCallback(componentsCallback ComponentsCallback) Option {
return func(o *runtimeOpts) {
o.componentsCallback = componentsCallback
}
}