Cadence is a distributed, scalable, durable, and highly available orchestration engine we developed at Uber Engineering to execute asynchronous long-running business logic in a scalable and resilient way.
cadence-client
is the framework for authoring workflows and activities in Go.
If you are authoring in Java, see Java Cadence Client.
Clone this repo into the correct location:
git clone git@github.com:uber-go/cadence-client.git $GOPATH/src/go.uber.org/cadence
or
go get go.uber.org/cadence
For samples, see Cadence Samples.
Run Cadence Server using Docker Compose:
curl -O https://raw.githubusercontent.com/uber/cadence/master/docker/docker-compose.yml
docker-compose up
If this does not work, see instructions for running the Cadence Server at https://github.com/uber/cadence/blob/master/README.md.
Following code demonstrates a sample workflow. For detailed information about the code, see Workflows.
package simple
import (
"time"
"go.uber.org/cadence/workflow"
"go.uber.org/zap"
)
func init() {
workflow.Register(SimpleWorkflow)
}
// SimpleWorkflow is a sample Cadence workflow that accepts one parameter and
// executes an activity to which it passes the aforementioned parameter.
func SimpleWorkflow(ctx workflow.Context, value string) error {
options := workflow.ActivityOptions{
ScheduleToStartTimeout: time.Second * 60,
StartToCloseTimeout: time.Second * 60,
}
ctx = workflow.WithActivityOptions(ctx, options)
var result string
err := workflow.ExecuteActivity(ctx, activity.SimpleActivity, value).Get(ctx, &result)
if err != nil {
return err
}
workflow.GetLogger(ctx).Info(
"SimpleActivity returned successfully!", zap.String("Result", result))
workflow.GetLogger(ctx).Info("SimpleWorkflow completed!")
return nil
}
We'd love your help in making Cadence-client great. Please review our instructions.
MIT License, please see LICENSE for details.