Skip to content

Commit c0a074b

Browse files
authored
Change all samples to use envconfig to connect to client (#421)
1 parent c97a985 commit c0a074b

28 files changed

Lines changed: 60 additions & 30 deletions

File tree

batch-sliding-window/starter/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import (
66

77
batch_sliding_window "github.com/temporalio/samples-go/batch-sliding-window"
88
"go.temporal.io/sdk/client"
9+
"go.temporal.io/sdk/contrib/envconfig"
910
)
1011

1112
func main() {
12-
c, err := client.Dial(client.Options{})
13+
c, err := client.Dial(envconfig.MustLoadDefaultClientOptions())
1314
if err != nil {
1415
panic(err)
1516
}

branch/starter/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import (
55
"log"
66

77
"go.temporal.io/sdk/client"
8+
"go.temporal.io/sdk/contrib/envconfig"
89

910
"github.com/temporalio/samples-go/branch"
1011
)
1112

1213
// @@@SNIPSTART samples-go-branch-workflow-execution-starter
1314
func main() {
1415
// The client is a heavyweight object that should be created only once per process.
15-
c, err := client.Dial(client.Options{})
16+
c, err := client.Dial(envconfig.MustLoadDefaultClientOptions())
1617
if err != nil {
1718
panic(err)
1819
}

eager-workflow-start/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/pborman/uuid"
88
"go.temporal.io/sdk/client"
9+
"go.temporal.io/sdk/contrib/envconfig"
910
"go.temporal.io/sdk/worker"
1011

1112
"github.com/temporalio/samples-go/helloworld"
@@ -15,7 +16,7 @@ const taskQueueName = "eager_wf_start"
1516

1617
func main() {
1718
// 1. Create the shared client.
18-
c, err := client.Dial(client.Options{})
19+
c, err := client.Dial(envconfig.MustLoadDefaultClientOptions())
1920
if err != nil {
2021
log.Fatalln("Unable to create client", err)
2122
}

early-return/starter/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import (
99
"github.com/temporalio/samples-go/early-return"
1010
enumspb "go.temporal.io/api/enums/v1"
1111
"go.temporal.io/sdk/client"
12+
"go.temporal.io/sdk/contrib/envconfig"
1213
)
1314

1415
func main() {
15-
c, err := client.Dial(client.Options{})
16+
c, err := client.Dial(envconfig.MustLoadDefaultClientOptions())
1617
if err != nil {
1718
log.Fatalln("Unable to create client", err)
1819
}

early-return/worker/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55

66
"github.com/temporalio/samples-go/early-return"
77
"go.temporal.io/sdk/client"
8+
"go.temporal.io/sdk/contrib/envconfig"
89
"go.temporal.io/sdk/worker"
910
)
1011

1112
func main() {
1213
// The client and worker are heavyweight objects that should be created once per process.
13-
c, err := client.Dial(client.Options{})
14+
c, err := client.Dial(envconfig.MustLoadDefaultClientOptions())
1415
if err != nil {
1516
log.Fatalln("Unable to create client", err)
1617
}

logger-interceptor/starter/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import (
66

77
"github.com/temporalio/samples-go/logger-interceptor"
88
"go.temporal.io/sdk/client"
9+
"go.temporal.io/sdk/contrib/envconfig"
910
)
1011

1112
func main() {
1213
// The client is a heavyweight object that should be created once per process.
13-
c, err := client.Dial(client.Options{})
14+
c, err := client.Dial(envconfig.MustLoadDefaultClientOptions())
1415
if err != nil {
1516
log.Fatalln("Unable to create client", err)
1617
}

logger-interceptor/worker/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import (
88
"github.com/temporalio/samples-go/logger-interceptor"
99
"go.temporal.io/sdk/activity"
1010
"go.temporal.io/sdk/client"
11+
"go.temporal.io/sdk/contrib/envconfig"
1112
sdkinterceptor "go.temporal.io/sdk/interceptor"
1213
"go.temporal.io/sdk/worker"
1314
"go.temporal.io/sdk/workflow"
1415
)
1516

1617
func main() {
1718
// The client and worker are heavyweight objects that should be created once per process.
18-
c, err := client.Dial(client.Options{})
19+
c, err := client.Dial(envconfig.MustLoadDefaultClientOptions())
1920
if err != nil {
2021
log.Fatalln("Unable to create client", err)
2122
}

metrics/starter/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"log"
66

77
"go.temporal.io/sdk/client"
8+
"go.temporal.io/sdk/contrib/envconfig"
89

910
"github.com/temporalio/samples-go/metrics"
1011
)
1112

1213
func main() {
1314
// The client is a heavyweight object that should be created once per process.
14-
c, err := client.Dial(client.Options{})
15+
c, err := client.Dial(envconfig.MustLoadDefaultClientOptions())
1516
if err != nil {
1617
log.Fatalln("Unable to create client.", err)
1718
}

multi-history-replay/replayer/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
workflowpb "go.temporal.io/api/workflow/v1"
99
"go.temporal.io/api/workflowservice/v1"
1010
"go.temporal.io/sdk/client"
11+
"go.temporal.io/sdk/contrib/envconfig"
1112
"go.temporal.io/sdk/worker"
1213
"go.temporal.io/sdk/workflow"
1314
)
@@ -34,7 +35,7 @@ func GetWorkflows(ctx context.Context, c client.Client, query string) ([]*workfl
3435

3536
func main() {
3637
// The client is a heavyweight object that should be created once per process.
37-
c, err := client.Dial(client.Options{})
38+
c, err := client.Dial(envconfig.MustLoadDefaultClientOptions())
3839
if err != nil {
3940
log.Fatalln("Unable to create client", err)
4041
}

multi-history-replay/starter/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import (
66

77
"github.com/temporalio/samples-go/helloworld"
88
"go.temporal.io/sdk/client"
9+
"go.temporal.io/sdk/contrib/envconfig"
910
)
1011

1112
func main() {
1213
// The client is a heavyweight object that should be created once per process.
13-
c, err := client.Dial(client.Options{})
14+
c, err := client.Dial(envconfig.MustLoadDefaultClientOptions())
1415
if err != nil {
1516
log.Fatalln("Unable to create client", err)
1617
}

0 commit comments

Comments
 (0)