Skip to content

Commit

Permalink
Update workflow package registration notes (#355)
Browse files Browse the repository at this point in the history
Signed-off-by: Jesús García Crespo <jesus@sevein.com>

Co-authored-by: Vitaly <Vitaly.Arbuzov@gmail.com>
  • Loading branch information
sevein and vitarb committed Feb 16, 2021
1 parent a97e3b2 commit 000fce6
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions workflow/doc.go
Expand Up @@ -49,10 +49,6 @@ the sole parameter it receives as part of its initialization as a parameter to t
"go.temporal.io/sdk/workflow"
)
func init() {
workflow.Register(SimpleWorkflow)
}
func SimpleWorkflow(ctx workflow.Context, value string) error {
ao := workflow.ActivityOptions{
TaskQueue: "sampleTaskQueue",
Expand Down Expand Up @@ -463,12 +459,17 @@ Registration
For some client code to be able to invoke a workflow type, the worker process needs to be aware of all the
implementations it has access to. A workflow is registered with the following call:
workflow.Register(SimpleWorkflow)
worker.RegisterWorkflow(SimpleWorkflow)
This call essentially creates an in memory mapping inside the worker process between the fully qualified function name
and the implementation. It is safe to call this registration method from an **init()** function. If the worker
receives tasks for a workflow type it does not know it will fail that task. However, the failure of the task will not
cause the entire workflow to fail.
and the implementation. If the worker receives tasks for a workflow type it does not know it will fail that task.
However, the failure of the task will not cause the entire workflow to fail.
Similarly, we need to have at least one worker that hosts the activity functions:
worker.RegisterActivity(MyActivity)
See the activity package for more details on activity registration.
Testing
Expand Down

0 comments on commit 000fce6

Please sign in to comment.