Skip to content

Commit

Permalink
Switch cadence-samples to gRPC (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
vytautas-karpavicius committed Oct 14, 2021
1 parent 66b7758 commit f7d131a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Run Cadence Server

See instructions for running the Cadence Server: https://github.com/uber/cadence/blob/master/README.md

See instructions for using CLI to register a domain(name as "samples-domain"): https://cadenceworkflow.io/docs/08_cli
or https://github.com/uber/cadence/blob/master/tools/cli/README.md
See instructions for using CLI to register a domain(name as "samples-domain"): https://cadenceworkflow.io/docs/cli/#quick-start
or https://github.com/uber/cadence/blob/master/tools/cli/README.md


## Steps to run samples
### Build Samples
```
Expand Down Expand Up @@ -156,4 +156,4 @@ See more details in https://github.com/uber-common/cadence-samples/blob/master/c
See more details in https://github.com/uber-common/cadence-samples/blob/master/cmd/samples/recipes/query/README.md

#### recovery
See more details in https://github.com/uber-common/cadence-samples/blob/master/cmd/samples/recovery/README.md
See more details in https://github.com/uber-common/cadence-samples/blob/master/cmd/samples/recovery/README.md
20 changes: 11 additions & 9 deletions cmd/samples/common/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import (

"github.com/uber-go/tally"
"go.uber.org/cadence/.gen/go/cadence/workflowserviceclient"
apiv1 "go.uber.org/cadence/.gen/proto/api/v1"
"go.uber.org/cadence/client"
"go.uber.org/cadence/compatibility"
"go.uber.org/cadence/encoded"
"go.uber.org/cadence/workflow"
"go.uber.org/yarpc"
"go.uber.org/yarpc/transport/tchannel"
"go.uber.org/yarpc/transport/grpc"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -130,7 +132,13 @@ func (b *WorkflowClientBuilder) BuildServiceClient() (workflowserviceclient.Inte
b.Logger.Fatal("No RPC dispatcher provided to create a connection to Cadence Service")
}

return workflowserviceclient.New(b.dispatcher.ClientConfig(_cadenceFrontendService)), nil
clientConfig := b.dispatcher.ClientConfig(_cadenceFrontendService)
return compatibility.NewThrift2ProtoAdapter(
apiv1.NewDomainAPIYARPCClient(clientConfig),
apiv1.NewWorkflowAPIYARPCClient(clientConfig),
apiv1.NewWorkerAPIYARPCClient(clientConfig),
apiv1.NewVisibilityAPIYARPCClient(clientConfig),
), nil
}

func (b *WorkflowClientBuilder) build() error {
Expand All @@ -142,20 +150,14 @@ func (b *WorkflowClientBuilder) build() error {
return errors.New("HostPort is empty")
}

ch, err := tchannel.NewChannelTransport(
tchannel.ServiceName(_cadenceClientName))
if err != nil {
b.Logger.Fatal("Failed to create transport channel", zap.Error(err))
}

b.Logger.Debug("Creating RPC dispatcher outbound",
zap.String("ServiceName", _cadenceFrontendService),
zap.String("HostPort", b.hostPort))

b.dispatcher = yarpc.NewDispatcher(yarpc.Config{
Name: _cadenceClientName,
Outbounds: yarpc.Outbounds{
_cadenceFrontendService: {Unary: ch.NewSingleOutbound(b.hostPort)},
_cadenceFrontendService: {Unary: grpc.NewTransport().NewSingleOutbound(b.hostPort)},
},
})

Expand Down
2 changes: 1 addition & 1 deletion config/development.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# config for sample
domain: "samples-domain"
service: "cadence-frontend"
host: "127.0.0.1:7933"
host: "127.0.0.1:7833"
# config for emitting metrics
#prometheus:
# listenAddress: "127.0.0.1:9098"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.4.0
github.com/uber-go/tally v3.3.15+incompatible
go.uber.org/cadence v0.17.1-0.20210708064625-c4a7e032cc13
go.uber.org/cadence v0.18.3
go.uber.org/yarpc v1.55.0
go.uber.org/zap v1.13.0
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.5.1/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/cadence v0.17.1-0.20210708064625-c4a7e032cc13 h1:y8xZTdnsUb3Ssk9RwfT/TON9jZeQPKP0/DsIMr1rvtI=
go.uber.org/cadence v0.17.1-0.20210708064625-c4a7e032cc13/go.mod h1:h3zIdrjSTr6FXkLawgWI4QYhGW6OrLqbD2fRt8kEmjI=
go.uber.org/cadence v0.18.3 h1:AdkNF6RwJGgBBUWHI/2HbuRRVhIqqxVpsOY0C+WnnFk=
go.uber.org/cadence v0.18.3/go.mod h1:h3zIdrjSTr6FXkLawgWI4QYhGW6OrLqbD2fRt8kEmjI=
go.uber.org/dig v1.8.0/go.mod h1:X34SnWGr8Fyla9zQNO2GSO2D+TIuqB14OS8JhYocIyw=
go.uber.org/dig v1.10.0 h1:yLmDDj9/zuDjv3gz8GQGviXMs9TfysIUMUilCpgzUJY=
go.uber.org/dig v1.10.0/go.mod h1:X34SnWGr8Fyla9zQNO2GSO2D+TIuqB14OS8JhYocIyw=
Expand Down

0 comments on commit f7d131a

Please sign in to comment.