@@ -37,6 +37,26 @@ type (
37
37
// Worker hosts workflow and activity implementations.
38
38
// Use worker.New(...) to create an instance.
39
39
Worker interface {
40
+ Registry
41
+
42
+ // Start starts the worker in a non-blocking fashion
43
+ Start () error
44
+ // Run is a blocking start and cleans up resources when killed
45
+ // returns error only if it fails to start the worker
46
+ Run () error
47
+ // Stop cleans up any resources opened by worker
48
+ Stop ()
49
+ }
50
+
51
+
52
+ // Registry exposes registration functions to consumers.
53
+ Registry interface {
54
+ WorkflowRegistry
55
+ ActivityRegistry
56
+ }
57
+
58
+ // WorkflowRegistry exposes workflow registration functions to consumers.
59
+ WorkflowRegistry interface {
40
60
// RegisterWorkflow - registers a workflow function with the worker.
41
61
// A workflow takes a workflow.Context and input and returns a (result, error) or just error.
42
62
// Examples:
@@ -57,7 +77,10 @@ type (
57
77
// This method panics if workflowFunc doesn't comply with the expected format or tries to register the same workflow
58
78
// type name twice. Use workflow.RegisterOptions.DisableAlreadyRegisteredCheck to allow multiple registrations.
59
79
RegisterWorkflowWithOptions (w interface {}, options workflow.RegisterOptions )
80
+ }
60
81
82
+ // ActivityRegistry exposes activity registration functions to consumers.
83
+ ActivityRegistry interface {
61
84
// RegisterActivity - register an activity function or a pointer to a structure with the worker.
62
85
// An activity function takes a context and input and returns a (result, error) or just error.
63
86
//
@@ -106,14 +129,6 @@ type (
106
129
// which might be useful for integration tests.
107
130
// worker.RegisterActivityWithOptions(barActivity, RegisterActivityOptions{DisableAlreadyRegisteredCheck: true})
108
131
RegisterActivityWithOptions (a interface {}, options activity.RegisterOptions )
109
-
110
- // Start starts the worker in a non-blocking fashion
111
- Start () error
112
- // Run is a blocking start and cleans up resources when killed
113
- // returns error only if it fails to start the worker
114
- Run () error
115
- // Stop cleans up any resources opened by worker
116
- Stop ()
117
132
}
118
133
119
134
// WorkflowReplayer supports replaying a workflow from its event history.
0 commit comments