Skip to content

Commit

Permalink
Merge pull request #3 from temporalio/abhinav/setAPIVersion
Browse files Browse the repository at this point in the history
Set api version
  • Loading branch information
anekkanti authored Oct 9, 2023
2 parents df93922 + 2028b4f commit 1dd4254
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 112 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ copy-api-cloud-api:
@printf $(COLOR) "Copy api-cloud..."
rm -rf $(PROTO_ROOT)/temporal/api
mkdir -p $(PROTO_ROOT)/temporal/api
git clone [email protected]:temporalio/api-cloud.git --depth=1 --branch abhinav/userMgmt --single-branch $(PROTO_ROOT)/api-cloud-tmp
git clone [email protected]:temporalio/api-cloud.git --depth=1 --branch main --single-branch $(PROTO_ROOT)/api-cloud-tmp
mv -f $(PROTO_ROOT)/api-cloud-tmp/temporal/api/cloud $(PROTO_ROOT)/temporal/api
mv $(PROTO_ROOT)/api-cloud-tmp/VERSION client/api/version
rm -rf $(PROTO_ROOT)/api-cloud-tmp

##### Compile proto files for go #####
Expand Down
22 changes: 17 additions & 5 deletions client/api/client.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package api

import (
"context"
"crypto/tls"
"fmt"
"net/url"
"strings"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

const (
VersionHeader = "cloud-operations-workflows-version"
CommitHeader = "cloud-operations-workflows-commit"
"google.golang.org/grpc/metadata"
)

func NewConnectionWithAPIKey(addrStr string, allowInsecure bool, apiKey string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
Expand Down Expand Up @@ -53,6 +51,20 @@ func defaultDialOptions(addr *url.URL, allowInsecure bool) ([]grpc.DialOption, e
if allowInsecure {
transport = insecure.NewCredentials()
}

opts = append(opts, grpc.WithTransportCredentials(transport))
opts = append(opts, grpc.WithUnaryInterceptor(setAPIVersionInterceptor))
return opts, nil
}

func setAPIVersionInterceptor(
ctx context.Context,
method string,
req, reply interface{},
cc *grpc.ClientConn,
invoker grpc.UnaryInvoker,
opts ...grpc.CallOption,
) error {
ctx = metadata.AppendToOutgoingContext(ctx, TemporalCloudAPIVersionHeader, strings.TrimSpace(TemporalCloudAPIVersion))
return invoker(ctx, method, req, reply, cc, opts...)
}
1 change: 1 addition & 0 deletions client/api/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-10-01-00
12 changes: 12 additions & 0 deletions client/api/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package api

import _ "embed"

const (
TemporalCloudAPIVersionHeader = "temporal-cloud-api-version"
)

var (
//go:embed version
TemporalCloudAPIVersion string
)
4 changes: 2 additions & 2 deletions cmd/worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Generate an apikey by either visiting the [Cloud UI](https://cloud.temporal.io/s
### Step 2: Start the worker
Start the worker using the APIKey
```
TEMPORAL_CLOUD_API_KEY=<apikey> go run ./demo
TEMPORAL_CLOUD_API_KEY=<apikey> go run ./cmd/worker
```

### Step 3: Run a workflow
Run a workflow using `tctl` for example to invoke `get-users` workflow run:
```
tctl wf start --tq demo --wt cloud-operations-workflows.get-users -i '{}'
tctl wf start --tq demo --wt tmprlcloud-wf.get-users -i '{}'
```

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions protogen/temporal/api/cloud/cloudservice/v1/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 25 additions & 15 deletions protogen/temporal/api/cloud/cloudservice/v1/service_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1dd4254

Please sign in to comment.