diff --git a/Makefile b/Makefile index b05efe1a..b08d2e46 100644 --- a/Makefile +++ b/Makefile @@ -40,13 +40,25 @@ update-proto-submodule: printf $(COLOR) "Update proto-submodule..." git -c protocol.file.allow=always submodule update --init --force --remote $(PROTO_ROOT) -##### Compile proto files for go ##### -grpc: http-api-docs go-grpc copy-helpers +NEXUS_SCHEMA_ROOT := $(PROTO_ROOT)/nexus +NEXUS_PROTO_OUT := workflowservice/v1/workflowservicenexus -# Only install helper when its source has changed +##### Compile proto files for go ##### +grpc: http-api-docs go-grpc copy-helpers nexus-gen + +nexus-gen: + printf $(COLOR) "Generate nexus service definitions..." + mkdir -p $(NEXUS_PROTO_OUT) + cd $(NEXUS_SCHEMA_ROOT) && nexus-rpc-gen \ + --lang go \ + --package workflowservicenexus \ + --out-file $(CURDIR)/$(NEXUS_PROTO_OUT)/service_nexus.pb.go \ + temporal-proto-models-nexusrpc.yaml + +# Only install helpers when their source has changed HELPER_FILES = $(shell find ./cmd/protoc-gen-go-helpers) .go-helpers-installed: $(HELPER_FILES) - printf $(COLOR) "Installing protoc plugin" + printf $(COLOR) "Installing protoc-gen-go-helpers plugin" @go install ./cmd/protoc-gen-go-helpers @touch $@ @@ -105,12 +117,23 @@ gen-proto-desc: --output-descriptor=$(PROTO_OUT)/descriptor_set.pb ##### Plugins & tools ##### -grpc-install: +grpc-install: nexus-rpc-gen-install @printf $(COLOR) "Install/update grpc and plugins..." - @go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + @go install google.golang.org/protobuf/cmd/protoc-gen-go@latest @go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest @go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest +NEXUS_RPC_GEN_CACHE := $(HOME)/.cache/nexus-rpc-gen + +.PHONY: nexus-rpc-gen-install +nexus-rpc-gen-install: + @printf $(COLOR) "Install nexus-rpc-gen from main..." + @rm -rf $(NEXUS_RPC_GEN_CACHE) + @git clone --depth 1 https://github.com/nexus-rpc/nexus-rpc-gen.git $(NEXUS_RPC_GEN_CACHE) + @cd $(NEXUS_RPC_GEN_CACHE)/src && pnpm install && pnpm run build + @chmod +x $(NEXUS_RPC_GEN_CACHE)/src/packages/nexus-rpc-gen/dist/index.js + @cd $(NEXUS_RPC_GEN_CACHE)/src/packages/nexus-rpc-gen && pnpm link --global + mockgen-install: printf $(COLOR) "Install/update mockgen..." go install -modfile=build/go.mod github.com/golang/mock/mockgen diff --git a/go.mod b/go.mod index 3b5eaef2..ef4fa0be 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/golang/mock v1.6.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 github.com/nexus-rpc/nexus-proto-annotations v0.1.0 + github.com/nexus-rpc/sdk-go v0.6.0 github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240827150818-7e3bb234dfed google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed diff --git a/go.sum b/go.sum index 49df761b..a17b93bc 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/nexus-rpc/nexus-proto-annotations v0.1.0 h1:2fELd+9sqUtNu6Fg//pw8YFsxOvp8vZ8hfP0nHhNI80= github.com/nexus-rpc/nexus-proto-annotations v0.1.0/go.mod h1:n3UjF1bPCW8llR8tHvbxJ+27yPWrhpo8w/Yg1IOuY0Y= +github.com/nexus-rpc/sdk-go v0.6.0 h1:QRgnP2zTbxEbiyWG/aXH8uSC5LV/Mg1fqb19jb4DBlo= +github.com/nexus-rpc/sdk-go v0.6.0/go.mod h1:FHdPfVQwRuJFZFTF0Y2GOAxCrbIBNrcPna9slkGKPYk= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= diff --git a/workflowservice/v1/workflowservicenexus/service_nexus.pb.go b/workflowservice/v1/workflowservicenexus/service_nexus.pb.go new file mode 100644 index 00000000..15dbdff5 --- /dev/null +++ b/workflowservice/v1/workflowservicenexus/service_nexus.pb.go @@ -0,0 +1,16 @@ +// Code generated by nexus-rpc-gen. DO NOT EDIT. + +package workflowservicenexus + +import ( + "github.com/nexus-rpc/sdk-go/nexus" + workflowservicev1 "go.temporal.io/api/workflowservice/v1" +) + +var WorkflowService = struct { + ServiceName string + SignalWithStartWorkflowExecution nexus.OperationReference[workflowservicev1.SignalWithStartWorkflowExecutionRequest, workflowservicev1.SignalWithStartWorkflowExecutionResponse] +}{ + ServiceName: "WorkflowService", + SignalWithStartWorkflowExecution: nexus.NewOperationReference[workflowservicev1.SignalWithStartWorkflowExecutionRequest, workflowservicev1.SignalWithStartWorkflowExecutionResponse]("SignalWithStartWorkflowExecution"), +}