目錄
問題內容
解決方法
首頁 後端開發 Golang 無法從 GoLang 運行 Cadence 工作流程

無法從 GoLang 運行 Cadence 工作流程

Feb 09, 2024 am 08:03 AM

无法从 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中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱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

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

Debian OpenSSL有哪些漏洞 Debian OpenSSL有哪些漏洞 Apr 02, 2025 am 07:30 AM

OpenSSL,作為廣泛應用於安全通信的開源庫,提供了加密算法、密鑰和證書管理等功能。然而,其歷史版本中存在一些已知安全漏洞,其中一些危害極大。本文將重點介紹Debian系統中OpenSSL的常見漏洞及應對措施。 DebianOpenSSL已知漏洞:OpenSSL曾出現過多個嚴重漏洞,例如:心臟出血漏洞(CVE-2014-0160):該漏洞影響OpenSSL1.0.1至1.0.1f以及1.0.2至1.0.2beta版本。攻擊者可利用此漏洞未經授權讀取服務器上的敏感信息,包括加密密鑰等。

Beego ORM中如何指定模型關聯的數據庫? Beego ORM中如何指定模型關聯的數據庫? Apr 02, 2025 pm 03:54 PM

在BeegoORM框架下,如何指定模型關聯的數據庫?許多Beego項目需要同時操作多個數據庫。當使用Beego...

從前端轉型後端開發,學習Java還是Golang更有前景? 從前端轉型後端開發,學習Java還是Golang更有前景? Apr 02, 2025 am 09:12 AM

後端學習路徑:從前端轉型到後端的探索之旅作為一名從前端開發轉型的後端初學者,你已經有了nodejs的基礎,...

GoLand中自定義結構體標籤不顯示怎麼辦? GoLand中自定義結構體標籤不顯示怎麼辦? Apr 02, 2025 pm 05:09 PM

GoLand中自定義結構體標籤不顯示怎麼辦?在使用GoLand進行Go語言開發時,很多開發者會遇到自定義結構體標籤在�...

在Go語言中使用Redis Stream實現消息隊列時,如何解決user_id類型轉換問題? 在Go語言中使用Redis Stream實現消息隊列時,如何解決user_id類型轉換問題? Apr 02, 2025 pm 04:54 PM

Go語言中使用RedisStream實現消息隊列時類型轉換問題在使用Go語言與Redis...

Go語言中用於浮點數運算的庫有哪些? Go語言中用於浮點數運算的庫有哪些? Apr 02, 2025 pm 02:06 PM

Go語言中用於浮點數運算的庫介紹在Go語言(也稱為Golang)中,進行浮點數的加減乘除運算時,如何確保精度是�...

Go的爬蟲Colly中Queue線程的問題是什麼? Go的爬蟲Colly中Queue線程的問題是什麼? Apr 02, 2025 pm 02:09 PM

Go爬蟲Colly中的Queue線程問題探討在使用Go語言的Colly爬蟲庫時,開發者常常會遇到關於線程和請求隊列的問題。 �...

在 Go 語言中,為什麼使用 Println 和 string() 函數打印字符串會出現不同的效果? 在 Go 語言中,為什麼使用 Println 和 string() 函數打印字符串會出現不同的效果? Apr 02, 2025 pm 02:03 PM

Go語言中字符串打印的區別:使用Println與string()函數的效果差異在Go...

See all articles