Skip to content

Commit 6df8d7a

Browse files
chore: api key support, simplify example (#419)
1 parent dacd61d commit 6df8d7a

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

helloworld-apiKey/helloworld.go

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"go.temporal.io/sdk/activity"
1212
"go.temporal.io/sdk/client"
1313
"go.temporal.io/sdk/workflow"
14-
"google.golang.org/grpc"
15-
"google.golang.org/grpc/metadata"
1614
)
1715

1816
// Workflow is a Hello World workflow definition.
@@ -64,29 +62,10 @@ func ParseClientOptionFlags(args []string) (client.Options, error) {
6462
return client.Options{}, fmt.Errorf("-api-key or TEMPORAL_CLIENT_API_KEY env is required required")
6563
}
6664

67-
connectionOptions := client.ConnectionOptions{
68-
TLS: &tls.Config{},
69-
DialOptions: []grpc.DialOption{
70-
grpc.WithUnaryInterceptor(
71-
func(ctx context.Context, method string, req any, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
72-
return invoker(
73-
metadata.AppendToOutgoingContext(ctx, "temporal-namespace", *namespace),
74-
method,
75-
req,
76-
reply,
77-
cc,
78-
opts...,
79-
)
80-
},
81-
),
82-
},
83-
}
84-
credentials := client.NewAPIKeyStaticCredentials(*apiKey)
85-
8665
return client.Options{
8766
HostPort: *targetHost,
8867
Namespace: *namespace,
89-
ConnectionOptions: connectionOptions,
90-
Credentials: credentials,
68+
ConnectionOptions: client.ConnectionOptions{TLS: &tls.Config{}},
69+
Credentials: client.NewAPIKeyStaticCredentials(*apiKey),
9170
}, nil
9271
}

0 commit comments

Comments
 (0)