猿问

Cadence 分别注册工作流程和活动

我有一个由多台机器组成的网络,并且我正在使用 cadence go 客户端。


机器 1 需要注册活动。


// Machine 1 registering activities

func sampleActivity(ctx context.Context) (string, error) {

    logger := activity.GetLogger(ctx)

    logger.Info("separate machines are handling this")

    return "Activity machine succeeded"

}

func main() {

     activity.RegisterWithOptions(sampleActivity, RegisterOptions{Name: "Machine1Activity"})

}

机器 2 需要注册工作流。


// Machine 2 registering workflows

func sample_workflow(ctx workflow.Context, name string) (string, error) {

     ...

     err := workflow.ExecuteActivity(ctx, "Machine1Activity")

     ...

}


func main() {

    workflow.RegisterWithOptions(sampleWorkflow, "Machine2Workflow")

}

机器 3 需要启动才能启动工作流程。


// Machine 3 starting the workflow


// Prepare options and ctx


client.StartWorkflow(ctx, options, "Machine2Workflow", "Machine1Activity")

cadence-fronted 服务在另一台机器上。


如何使用 go 客户端执行此操作?寄存器是否也仅将工作流/活动保存在内存中?如何将它们推送到 cadence 服务,以便其他机器也可以找到它们。


慕斯王
浏览 89回答 1
1回答

Cats萌萌

目前,注册对于特定的工作进程来说纯粹是本地的。我们计划在未来添加某种带有活动目录和工作流类型的元数据服务。要在机器 1 上禁用工作流工作者,请指定WorkerOptions.DisableWorkflowWorker.要在机器 2 上禁用活动工作者,请指定WorkerOptions.DisableActivityWorker.3.机器上不需要注册任何东西。
随时随地看视频慕课网APP

相关分类

Go
我要回答