The service half of protoc-gen-clojure's generated-code contract.
A generated file with a service emits exactly two calls here:
(def Greeter (rts/service file-descriptor "Greeter"))
(def greeter-methods (rts/methods-map Greeter))
service derives everything else — method names, streaming shapes,
request/response prototypes, and (lazily) grpc-java MethodDescriptors with
protobuf marshallers — from the FileDescriptor. The methods map is the bridge
both the server and client builders consume.
Pool discipline, the one subtle thing here: request/response prototypes must live in the same descriptor pool as the generated namespace's message prototypes, or the generated proto->X fns crash on parsed messages (protobuf-java forbids cross-pool field access). So prototypes are resolved exactly the way the emitter's hints are: a Java class name derived by the same rules protoc uses (only for java_multiple_files or edition-2024+ top-level classes — the same subset the plugin hints), verified against the descriptor, silently falling back to DynamicMessage over the SAME FileDescriptor instance the namespace's own prototypes use. Both arms align; being wrong costs the optimisation, never correctness.
The service half of protoc-gen-clojure's generated-code contract.
A generated file with a service emits exactly two calls here:
(def Greeter (rts/service file-descriptor "Greeter"))
(def greeter-methods (rts/methods-map Greeter))
`service` derives everything else — method names, streaming shapes,
request/response prototypes, and (lazily) grpc-java MethodDescriptors with
protobuf marshallers — from the FileDescriptor. The methods map is the bridge
both the server and client builders consume.
Pool discipline, the one subtle thing here: request/response prototypes must
live in the same descriptor pool as the generated namespace's message
prototypes, or the generated proto->X fns crash on parsed messages
(protobuf-java forbids cross-pool field access). So prototypes are resolved
exactly the way the emitter's hints are: a Java class name derived by the
same rules protoc uses (only for java_multiple_files or edition-2024+
top-level classes — the same subset the plugin hints), verified against the
descriptor, silently falling back to DynamicMessage over the SAME
FileDescriptor instance the namespace's own prototypes use. Both arms align;
being wrong costs the optimisation, never correctness.(methods-map svc){:kebab-method-key Method, ...} — the bridge shape the server and client builders consume.
{:kebab-method-key Method, ...} — the bridge shape the server and client
builders consume.(service fd service-name)The service value for a service declared in file-descriptor — the whole
generated-code contract for services.
The service value for a service declared in `file-descriptor` — the whole generated-code contract for services.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |