Table of Contents
Question content
Solution
Home Backend Development Golang Can't run Cadence workflow from GoLang

Can't run Cadence workflow from GoLang

Feb 09, 2024 am 08:03 AM

无法从 GoLang 运行 Cadence 工作流程

According to php editor Banana, some users have recently reported that they cannot successfully run the Cadence workflow in the GoLang environment. Cadence is a powerful distributed workflow engine, but you may encounter some problems in the GoLang environment. These issues may involve configuration, version compatibility, etc. If you encounter similar problems, you may try checking configuration and version compatibility, or consult official documentation and community discussions for more solutions.

Question content

I am very new to cadence and am trying to implement hello world, but the following error occurred

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}"}
Copy after login

The following is my Go code

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))
    }
}
Copy after login

These are the dependencies in my 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
)
Copy after login

Can anyone help?

Solution

The problem comes from this line we, err :=workflowClient.StartWorkflowExecution(context.Background(), &startRequest)

This is actually not a Cadence problem, but a yarpc problem. yarpc requires a context with a timeout, so if you change to use context.WithTimeout you should solve the first problem.

Another issue I noticed is that in the request, you may miss the RequestID field. It must be a UUID, so simply passing a string won't work. However, you don't need to specify them if you use the Cadence CLI to call the workflow directly. The CLI simplifies some input parameters, and this inconsistency is expected.

The above is the detailed content of Can't run Cadence workflow from GoLang. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do you use the pprof tool to analyze Go performance? How do you use the pprof tool to analyze Go performance? Mar 21, 2025 pm 06:37 PM

The article explains how to use the pprof tool for analyzing Go performance, including enabling profiling, collecting data, and identifying common bottlenecks like CPU and memory issues.Character count: 159

How do you write unit tests in Go? How do you write unit tests in Go? Mar 21, 2025 pm 06:34 PM

The article discusses writing unit tests in Go, covering best practices, mocking techniques, and tools for efficient test management.

How do I write mock objects and stubs for testing in Go? How do I write mock objects and stubs for testing in Go? Mar 10, 2025 pm 05:38 PM

This article demonstrates creating mocks and stubs in Go for unit testing. It emphasizes using interfaces, provides examples of mock implementations, and discusses best practices like keeping mocks focused and using assertion libraries. The articl

How can I define custom type constraints for generics in Go? How can I define custom type constraints for generics in Go? Mar 10, 2025 pm 03:20 PM

This article explores Go's custom type constraints for generics. It details how interfaces define minimum type requirements for generic functions, improving type safety and code reusability. The article also discusses limitations and best practices

How can I use tracing tools to understand the execution flow of my Go applications? How can I use tracing tools to understand the execution flow of my Go applications? Mar 10, 2025 pm 05:36 PM

This article explores using tracing tools to analyze Go application execution flow. It discusses manual and automatic instrumentation techniques, comparing tools like Jaeger, Zipkin, and OpenTelemetry, and highlighting effective data visualization

Explain the purpose of Go's reflect package. When would you use reflection? What are the performance implications? Explain the purpose of Go's reflect package. When would you use reflection? What are the performance implications? Mar 25, 2025 am 11:17 AM

The article discusses Go's reflect package, used for runtime manipulation of code, beneficial for serialization, generic programming, and more. It warns of performance costs like slower execution and higher memory use, advising judicious use and best

How do you use table-driven tests in Go? How do you use table-driven tests in Go? Mar 21, 2025 pm 06:35 PM

The article discusses using table-driven tests in Go, a method that uses a table of test cases to test functions with multiple inputs and outcomes. It highlights benefits like improved readability, reduced duplication, scalability, consistency, and a

How do you specify dependencies in your go.mod file? How do you specify dependencies in your go.mod file? Mar 27, 2025 pm 07:14 PM

The article discusses managing Go module dependencies via go.mod, covering specification, updates, and conflict resolution. It emphasizes best practices like semantic versioning and regular updates.

See all articles