根據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中文網其他相關文章!

C 更適合需要直接控制硬件資源和高性能優化的場景,而Golang更適合需要快速開發和高並發處理的場景。 1.C 的優勢在於其接近硬件的特性和高度的優化能力,適合遊戲開發等高性能需求。 2.Golang的優勢在於其簡潔的語法和天然的並發支持,適合高並發服務開發。

Golang在实际应用中表现出色,以简洁、高效和并发性著称。1)通过Goroutines和Channels实现并发编程,2)利用接口和多态编写灵活代码,3)使用net/http包简化网络编程,4)构建高效并发爬虫,5)通过工具和最佳实践进行调试和优化。

Go語言的核心特性包括垃圾回收、靜態鏈接和並發支持。 1.Go語言的並發模型通過goroutine和channel實現高效並發編程。 2.接口和多態性通過實現接口方法,使得不同類型可以統一處理。 3.基本用法展示了函數定義和調用的高效性。 4.高級用法中,切片提供了動態調整大小的強大功能。 5.常見錯誤如競態條件可以通過gotest-race檢測並解決。 6.性能優化通過sync.Pool重用對象,減少垃圾回收壓力。

Go語言在構建高效且可擴展的系統中表現出色,其優勢包括:1.高性能:編譯成機器碼,運行速度快;2.並發編程:通過goroutines和channels簡化多任務處理;3.簡潔性:語法簡潔,降低學習和維護成本;4.跨平台:支持跨平台編譯,方便部署。

關於SQL查詢結果排序的疑惑學習SQL的過程中,常常會遇到一些令人困惑的問題。最近,筆者在閱讀《MICK-SQL基礎�...

golang ...

Go語言中如何對比並處理三個結構體在Go語言編程中,有時需要對比兩個結構體的差異,並將這些差異應用到第�...


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

WebStorm Mac版
好用的JavaScript開發工具

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

Dreamweaver Mac版
視覺化網頁開發工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。