Skip to content

Commit ee45e7b

Browse files
authored
CHASM client codegen (temporalio#8398)
## What changed? Added a protoc plugin to generate client for internal CHASM requests to the history service. A CHASM library can now define its own set of gRPC services and register a handler for those. I had to modify the history client files to be generic, which broke the mock generation, so I had to hand code the tests there, which IMHO is actually nicer than the way they were with mocks. Also opted out of mock generation for CHASM services, there's just not enough value there. **NOTE**: Instead of creating three separate clients, I generated a single layered client, with a constructor that is DI friendly. There doesn't seem to be a good enough reason to break this out into separate clients or make client construction configurable (for now). **NOTE**: We can also get rid of the genrpcwrappers script eventually and use the protoc plugin approach for all services, I decided not to do that here though to reduce scope. For a preview of the generated file see: - https://github.com/bergundy/temporal/blob/3a89614a9097eca9061b5f347c01eda735534bbe/chasm/lib/activity/proto/v1/service.proto - https://github.com/bergundy/temporal/blob/3a89614a9097eca9061b5f347c01eda735534bbe/chasm/lib/activity/gen/activitypb/v1/service_client.pb.go ## Why? Keep all CHASM library functionality contained. ## How did you test it? - [ ] built
1 parent 02be124 commit ee45e7b

File tree

14 files changed

+735
-375
lines changed

14 files changed

+735
-375
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ $(STAMPDIR)/protoc-gen-go-helpers-$(GO_API_VER): | $(STAMPDIR) $(LOCALBIN)
270270
@touch $@
271271
$(PROTOC_GEN_GO_HELPERS): $(STAMPDIR)/protoc-gen-go-helpers-$(GO_API_VER)
272272

273+
$(LOCALBIN)/protoc-gen-go-chasm: $(LOCALBIN) cmd/tools/protoc-gen-go-chasm/main.go go.mod go.sum
274+
@go build -o $@ ./cmd/tools/protoc-gen-go-chasm
275+
273276
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
274277
# $1 - target path with name of binary (ideally with version)
275278
# $2 - package url which can be installed
@@ -300,7 +303,7 @@ $(CHASM_BINPB): $(API_BINPB) $(INTERNAL_BINPB) $(CHASM_PROTO_FILES)
300303
@printf $(COLOR) "Generate CHASM proto image..."
301304
@protoc --descriptor_set_in=$(API_BINPB):$(INTERNAL_BINPB) -I=. $(CHASM_PROTO_FILES) -o $@
302305

303-
protoc: $(PROTOGEN) $(MOCKGEN) $(GOIMPORTS) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) $(PROTOC_GEN_GO_HELPERS) $(API_BINPB)
306+
protoc: $(PROTOGEN) $(MOCKGEN) $(GOIMPORTS) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) $(PROTOC_GEN_GO_HELPERS) $(API_BINPB) $(LOCALBIN)/protoc-gen-go-chasm
304307
@go run ./cmd/tools/protogen \
305308
-root=$(ROOT) \
306309
-proto-out=$(PROTO_OUT) \
@@ -309,6 +312,7 @@ protoc: $(PROTOGEN) $(MOCKGEN) $(GOIMPORTS) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRP
309312
-protogen-bin=$(PROTOGEN) \
310313
-goimports-bin=$(GOIMPORTS) \
311314
-mockgen-bin=$(MOCKGEN) \
315+
-protoc-gen-go-chasm-bin=$(LOCALBIN)/protoc-gen-go-chasm \
312316
-protoc-gen-go-bin=$(PROTOC_GEN_GO) \
313317
-protoc-gen-go-grpc-bin=$(PROTOC_GEN_GO_GRPC) \
314318
-protoc-gen-go-helpers-bin=$(PROTOC_GEN_GO_HELPERS) \

api/routing/v1/extension.go-helpers.pb.go

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/routing/v1/extension.pb.go

Lines changed: 158 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)