Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions docker/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module mygomodule

go 1.25.2

require (
github.com/uber-go/tally v3.5.8+incompatible
github.com/uber/cadence-idl v0.0.0-20251006231722-792058c9dbad
go.uber.org/cadence v1.3.0
go.uber.org/yarpc v1.80.0
go.uber.org/zap v1.27.0
)

require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/apache/thrift v0.16.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/gogo/status v1.1.0 // indirect
github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
github.com/golang/mock v1.7.0-rc.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/jonboulle/clockwork v0.4.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-20160209185913-a97ce2ca70fa // 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/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/twmb/murmur3 v1.1.8 // indirect
github.com/uber-go/mapdecode v1.0.0 // indirect
github.com/uber/tchannel-go v1.34.4 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/dig v1.17.1 // indirect
go.uber.org/fx v1.22.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/net/metrics v1.4.0 // indirect
go.uber.org/thriftrw v1.32.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.0.0-20170927054726-6dc17368e09b // indirect
golang.org/x/tools v0.22.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.67.3 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.4.3 // indirect
)
427 changes: 427 additions & 0 deletions docker/go.sum

Large diffs are not rendered by default.

122 changes: 122 additions & 0 deletions docker/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package main

import (
"context"
"time"
"go.uber.org/cadence/activity"
"go.uber.org/cadence/workflow"
"net/http"
"go.uber.org/cadence/.gen/go/cadence/workflowserviceclient"
"go.uber.org/cadence/compatibility"
"go.uber.org/cadence/worker"

apiv1 "github.com/uber/cadence-idl/go/proto/api/v1"
"github.com/uber-go/tally"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"go.uber.org/yarpc"
"go.uber.org/yarpc/transport/grpc"
)

var HostPort = "127.0.0.1:7833"
var Domain = "test-domain"
var TaskListName = "test-worker"
var ClientName = "test-worker"
var CadenceService = "cadence-frontend"

func main() {
println("Starting Worker...")
startWorker(buildLogger(), buildCadenceClient())
err := http.ListenAndServe(":8080", nil)
if err != nil {
panic(err)
}
}

func buildLogger() *zap.Logger {
config := zap.NewDevelopmentConfig()
config.Level.SetLevel(zapcore.InfoLevel)

var err error
logger, err := config.Build()
if err != nil {
panic("Failed to setup logger")
}

return logger
}

func buildCadenceClient() workflowserviceclient.Interface {
dispatcher := yarpc.NewDispatcher(yarpc.Config{
Name: ClientName,
Outbounds: yarpc.Outbounds{
CadenceService: {Unary: grpc.NewTransport().NewSingleOutbound(HostPort)},
},
})
if err := dispatcher.Start(); err != nil {
panic("Failed to start dispatcher")
}

clientConfig := dispatcher.ClientConfig(CadenceService)

return compatibility.NewThrift2ProtoAdapter(
apiv1.NewDomainAPIYARPCClient(clientConfig),
apiv1.NewWorkflowAPIYARPCClient(clientConfig),
apiv1.NewWorkerAPIYARPCClient(clientConfig),
apiv1.NewVisibilityAPIYARPCClient(clientConfig),
)
}

func startWorker(logger *zap.Logger, service workflowserviceclient.Interface) {
// TaskListName identifies set of client workflows, activities, and workers.
// It could be your group or client or application name.
workerOptions := worker.Options{
Logger: logger,
MetricsScope: tally.NewTestScope(TaskListName, map[string]string{}),
}
worker.RegisterWorkflow(helloWorldWorkflow)
worker.RegisterActivity(helloWorldActivity)

worker, err := worker.NewV2(
service,
Domain,
TaskListName,
workerOptions)
if err != nil {
panic("Failed to initialize worker")
}

err = worker.Start()
if err != nil {
panic("Failed to start worker")
}

logger.Info("Started Worker.", zap.String("worker", TaskListName))
}
func helloWorldWorkflow(ctx workflow.Context, name string) (*string, error) {
ao := workflow.ActivityOptions{
ScheduleToStartTimeout: time.Minute,
StartToCloseTimeout: time.Minute,
HeartbeatTimeout: time.Second * 20,
}
ctx = workflow.WithActivityOptions(ctx, ao)

logger := workflow.GetLogger(ctx)
logger.Info("helloworld workflow started")
var helloworldResult string
err := workflow.ExecuteActivity(ctx, helloWorldActivity, name).Get(ctx, &helloworldResult)
if err != nil {
logger.Error("Activity failed.", zap.Error(err))
return nil, err
}

logger.Info("Workflow completed.", zap.String("Result", helloworldResult))

return &helloworldResult, nil
}

func helloWorldActivity(ctx context.Context, name string) (string, error) {
logger := activity.GetLogger(ctx)
logger.Info("helloworld activity started")
return "Hello " + name + "!", nil
}
46 changes: 23 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ require (
github.com/dave/dst v0.26.2
github.com/davecgh/go-spew v1.1.1
github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da
github.com/emirpasic/gods v0.0.0-20190624094223-e689965507ab
github.com/emirpasic/gods v1.18.1
github.com/fatih/color v1.13.0
github.com/go-sql-driver/mysql v1.7.1
github.com/gocql/gocql v0.0.0-20211015133455-b225f9b53fa1
github.com/gogo/protobuf v1.3.2
github.com/golang-jwt/jwt/v5 v5.2.0
github.com/golang/mock v1.6.0
github.com/golang/mock v1.7.0-rc.1
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
github.com/hashicorp/go-version v1.2.0
Expand All @@ -38,30 +38,30 @@ require (
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/startreedata/pinot-client-go v0.2.0 // latest release supports pinot v0.12.0 which is also internal version
github.com/stretchr/testify v1.10.0
github.com/uber-go/tally v3.3.15+incompatible
github.com/uber-go/tally v3.5.8+incompatible
github.com/uber/cadence-idl v0.0.0-20251002070144-16af6755557f
github.com/uber/ringpop-go v0.8.5
github.com/uber/tchannel-go v1.22.2
github.com/uber/tchannel-go v1.34.4
github.com/urfave/cli/v2 v2.27.4
github.com/valyala/fastjson v1.4.1
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
go.mongodb.org/mongo-driver v1.7.3
go.uber.org/atomic v1.10.0
go.uber.org/atomic v1.11.0
go.uber.org/cadence v0.19.0
go.uber.org/config v1.4.0
go.uber.org/fx v1.23.0
go.uber.org/multierr v1.10.0
go.uber.org/thriftrw v1.29.2
go.uber.org/yarpc v1.70.3
go.uber.org/zap v1.26.0
go.uber.org/multierr v1.11.0
go.uber.org/thriftrw v1.32.0
go.uber.org/yarpc v1.80.0
go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b
golang.org/x/net v0.40.0
golang.org/x/sync v0.14.0
golang.org/x/time v0.5.0
golang.org/x/tools v0.22.0
gonum.org/v1/gonum v0.7.0
google.golang.org/grpc v1.59.0
google.golang.org/grpc v1.67.3
gopkg.in/validator.v2 v2.0.0-20180514200540-135c24b11c19
gopkg.in/yaml.v2 v2.4.0
)
Expand All @@ -82,19 +82,19 @@ require (
github.com/ncruces/julianday v1.0.0 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
github.com/tetratelabs/wazero v1.8.2 // indirect
github.com/twmb/murmur3 v1.1.8 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
)

require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 // indirect
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
github.com/apache/thrift v0.17.0 // indirect
github.com/benbjohnson/clock v0.0.0-20161215174838-7dc76406b6d3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/cristalhq/jwt/v3 v3.1.0 // indirect
github.com/eapache/go-resiliency v1.7.0 // indirect
Expand All @@ -104,9 +104,9 @@ require (
github.com/fatih/structtag v1.2.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-zookeeper/zk v1.0.3 // indirect
github.com/gogo/googleapis v1.3.2 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/status v1.1.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed
github.com/hashicorp/errwrap v1.0.0 // indirect
Expand All @@ -117,9 +117,9 @@ require (
github.com/jcmturner/gofork v1.7.6 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jessevdk/go-flags v1.4.0 // indirect
github.com/jessevdk/go-flags v1.5.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kisielk/errcheck v1.5.0 // indirect
github.com/kisielk/errcheck v1.7.0 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/m3db/prometheus_client_model v0.1.0 // indirect
github.com/m3db/prometheus_common v0.1.0 // indirect
Expand Down Expand Up @@ -147,19 +147,19 @@ require (
github.com/xdg/stringprep v1.0.0 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.uber.org/dig v1.18.0 // indirect
go.uber.org/goleak v1.2.0
go.uber.org/net/metrics v1.3.0 // indirect
go.uber.org/goleak v1.3.0
go.uber.org/net/metrics v1.4.0 // indirect
golang.org/x/crypto v0.38.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.18.0
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.25.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.3.2 // indirect
honnef.co/go/tools v0.4.3 // indirect
)

// ringpop-go and tchannel-go depends on older version of thrift, yarpc brings up newer version
Expand Down
Loading