搜索
首页后端开发Golang无法从 GoLang 运行 Cadence 工作流程

无法从 GoLang 运行 Cadence 工作流程

据php小编香蕉了解,最近有用户反映在GoLang环境中无法成功运行Cadence工作流程。Cadence是一款强大的分布式工作流引擎,但在GoLang环境下可能会遇到一些问题。这些问题可能涉及到配置、版本兼容性等方面。如果你也遇到类似的问题,不妨尝试检查配置和版本兼容性,或者查阅官方文档和社区讨论,以获取更多解决方案。

问题内容

我对 cadence 很陌生,正在尝试实现 hello world,但出现了以下错误

2023-10-05T10:30:50.695+0530    INFO    internal/internal_worker.go:834 Started Workflow Worker {"Domain": "test-domain", "TaskList": "cadence-samples-worker", "WorkerID": "[email protected]@cadence-samples-worker@256dcb1f-1769-4183-9604-174160f79e7a"}
2023-10-05T10:30:50.724+0530    INFO    internal/internal_worker.go:859 Started Activity Worker {"Domain": "test-domain", "TaskList": "cadence-samples-worker", "WorkerID": "[email protected]@cadence-samples-worker@256dcb1f-1769-4183-9604-174160f79e7a"}
2023-10-05T10:30:50.724+0530    INFO    cadence-test/worker.go:49       Started Worker. {"worker": "cadence-samples-worker"}
2023-10-05T10:30:50.724+0530    ERROR   cadence-test/trigger.go:32      Failed to create workflow       {"error": "BadRequestError{Message: missing TTL}"}

下面是我的 Go 代码

func startWorkflow() {
    // This workflow ID can be user business logic identifier as well.
    workflowID := "cron_" + uuid.New().String()
    startTime := int32(60)
    domainName := "test-domain"

    logger, workflowClient := BuildLogger(), BuildCadenceClient()

    startRequest := shared.StartWorkflowExecutionRequest{
        WorkflowId: &workflowID,
        Domain:     &domainName,
        TaskList: &shared.TaskList{
            Name: &domainName,
        },
        ExecutionStartToCloseTimeoutSeconds: &startTime,
        TaskStartToCloseTimeoutSeconds:      &startTime,
        //DecisionTaskStartToCloseTimeout: time.Minute,

    }

    we, err := workflowClient.StartWorkflowExecution(context.Background(), &startRequest)
    if err != nil {
        logger.Error("Failed to create workflow", zap.Error(err))
        panic("Failed to create workflow.")
    } else {
        logger.Info("Started Workflow", zap.String("WorkflowID", *we.RunId), zap.String("RunID", *we.RunId))
    }
}

这些是我的 go.mod 中的依赖项

module cadence-test

go 1.21

require (
    github.com/google/uuid v1.3.0
    github.com/uber-go/tally v3.3.15+incompatible
    github.com/uber/cadence-idl v0.0.0-20230905165949-03586319b849
    go.uber.org/cadence v1.0.2
    go.uber.org/yarpc v1.70.4
    go.uber.org/zap v1.13.0
)

require (
    github.com/BurntSushi/toml v0.4.1 // indirect
    github.com/apache/thrift v0.16.0 // indirect
    github.com/beorn7/perks v1.0.1 // indirect
    github.com/cespare/xxhash/v2 v2.1.1 // indirect
    github.com/cristalhq/jwt/v3 v3.1.0 // indirect
    github.com/davecgh/go-spew v1.1.1 // indirect
    github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
    github.com/go-ole/go-ole v1.2.6 // indirect
    github.com/gogo/googleapis v1.3.2 // indirect
    github.com/gogo/protobuf v1.3.2 // indirect
    github.com/gogo/status v1.1.0 // indirect
    github.com/golang/mock v1.6.0 // indirect
    github.com/golang/protobuf v1.5.2 // indirect
    github.com/google/go-cmp v0.5.8 // indirect
    github.com/kr/pretty v0.3.0 // indirect
    github.com/marusama/semaphore/v2 v2.5.0 // indirect
    github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
    github.com/opentracing/opentracing-go v1.2.0 // indirect
    github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709 // indirect
    github.com/pmezard/go-difflib v1.0.0 // indirect
    github.com/prometheus/client_golang v1.11.1 // indirect
    github.com/prometheus/client_model v0.2.0 // indirect
    github.com/prometheus/common v0.26.0 // indirect
    github.com/prometheus/procfs v0.6.0 // indirect
    github.com/robfig/cron v1.2.0 // indirect
    github.com/shirou/gopsutil v3.21.11+incompatible // indirect
    github.com/stretchr/objx v0.5.0 // indirect
    github.com/stretchr/testify v1.8.1 // indirect
    github.com/tklauser/go-sysconf v0.3.11 // indirect
    github.com/tklauser/numcpus v0.6.0 // indirect
    github.com/uber-go/mapdecode v1.0.0 // indirect
    github.com/uber/tchannel-go v1.33.0 // indirect
    github.com/yusufpapurcu/wmi v1.2.3 // indirect
    go.uber.org/atomic v1.10.0 // indirect
    go.uber.org/dig v1.10.0 // indirect
    go.uber.org/fx v1.13.1 // indirect
    go.uber.org/multierr v1.6.0 // indirect
    go.uber.org/net/metrics v1.3.0 // indirect
    go.uber.org/thriftrw v1.29.2 // indirect
    golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect
    golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
    golang.org/x/mod v0.8.0 // indirect
    golang.org/x/net v0.14.0 // indirect
    golang.org/x/sys v0.11.0 // indirect
    golang.org/x/text v0.12.0 // indirect
    golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
    golang.org/x/tools v0.6.0 // indirect
    google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
    google.golang.org/grpc v1.47.0 // indirect
    google.golang.org/protobuf v1.28.0 // indirect
    gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
    gopkg.in/yaml.v2 v2.4.0 // indirect
    gopkg.in/yaml.v3 v3.0.1 // indirect
    honnef.co/go/tools v0.3.2 // indirect
)

有人可以帮忙吗?

解决方法

问题来自这一行 we, err :=workflowClient.StartWorkflowExecution(context.Background(), &startRequest)

这实际上不是 Cadence 问题,而是 yarpc 问题。 yarpc 需要一个带有超时的上下文,因此如果您更改为使用 context.WithTimeout,您应该解决第一个问题。

我注意到的另一个问题是,在请求中,您可能会错过 RequestID 字段。它必须是 UUID,因此简单地传递字符串是行不通的。但是,如果您使用Cadence CLI直接调用工作流程,则不需要指定它们。 CLI 简化了一些输入参数,这种不一致是预料之中的。

以上是无法从 GoLang 运行 Cadence 工作流程的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文转载于:stackoverflow。如有侵权,请联系admin@php.cn删除
初始功能和副作用:平衡初始化与可维护性初始功能和副作用:平衡初始化与可维护性Apr 26, 2025 am 12:23 AM

Toensureinitfunctionsareeffectiveandmaintainable:1)Minimizesideeffectsbyreturningvaluesinsteadofmodifyingglobalstate,2)Ensureidempotencytohandlemultiplecallssafely,and3)Breakdowncomplexinitializationintosmaller,focusedfunctionstoenhancemodularityandm

开始GO:初学者指南开始GO:初学者指南Apr 26, 2025 am 12:21 AM

goisidealforbeginnersandsubableforforcloudnetworkservicesduetoitssimplicity,效率和concurrencyFeatures.1)installgromtheofficialwebsitealwebsiteandverifywith'.2)

进行并发模式:开发人员的最佳实践进行并发模式:开发人员的最佳实践Apr 26, 2025 am 12:20 AM

开发者应遵循以下最佳实践:1.谨慎管理goroutines以防止资源泄漏;2.使用通道进行同步,但避免过度使用;3.在并发程序中显式处理错误;4.了解GOMAXPROCS以优化性能。这些实践对于高效和稳健的软件开发至关重要,因为它们确保了资源的有效管理、同步的正确实现、错误的适当处理以及性能的优化,从而提升软件的效率和可维护性。

进行生产:现实世界的用例和示例进行生产:现实世界的用例和示例Apr 26, 2025 am 12:18 AM

Goexcelsinproductionduetoitsperformanceandsimplicity,butrequirescarefulmanagementofscalability,errorhandling,andresources.1)DockerusesGoforefficientcontainermanagementthroughgoroutines.2)UberscalesmicroserviceswithGo,facingchallengesinservicemanageme

go中的自定义错误类型:提供详细的错误信息go中的自定义错误类型:提供详细的错误信息Apr 26, 2025 am 12:09 AM

我们需要自定义错误类型,因为标准错误接口提供的信息有限,自定义类型能添加更多上下文和结构化信息。1)自定义错误类型能包含错误代码、位置、上下文数据等,2)提高调试效率和用户体验,3)但需注意其复杂性和维护成本。

使用GO编程语言构建可扩展系统使用GO编程语言构建可扩展系统Apr 25, 2025 am 12:19 AM

goisidealforbuildingscalablesystemsduetoitssimplicity,效率和建筑物内currencysupport.1)go'scleansyntaxandaxandaxandaxandMinimalisticDesignenhanceProductivityAndRedCoductivityAndRedCuceErr.2)ItSgoroutinesAndInesAndInesAndInesAndineSandChannelsEnablenableNablenableNableNablenableFifficConcurrentscorncurrentprogragrammentworking torkermenticmminging

有效地使用Init功能的最佳实践有效地使用Init功能的最佳实践Apr 25, 2025 am 12:18 AM

Initfunctionsingorunautomationbeforemain()andareusefulforsettingupenvorments和InitializingVariables.usethemforsimpletasks,避免使用辅助效果,andbecautiouswithTestingTestingTestingAndLoggingTomaintAnainCodeCodeCodeClarityAndTestesto。

INIT函数在GO软件包中的执行顺序INIT函数在GO软件包中的执行顺序Apr 25, 2025 am 12:14 AM

goinitializespackagesintheordertheordertheyimported,thenexecutesInitFunctionswithinApcageIntheirdeFinityOrder,andfilenamesdetermineTheOrderAcractacractacrosmultiplefiles.thisprocessCanbeCanbeinepessCanbeInfleccessByendercrededBydeccredByDependenciesbetenciesbetencemendencenciesbetnependendpackages,whermayleLeadtocomplexinitialitialializizesizization

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

将Eclipse与SAP NetWeaver应用服务器集成。

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器

EditPlus 中文破解版

EditPlus 中文破解版

体积小,语法高亮,不支持代码提示功能

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。