Scaffolding gRPC
The Kratos Connection.
Experience blazing-fast, binary-efficient communication between your services. GO-DUCK automatically generates production-ready gRPC schemas and Kratos service implementations for every GDL entity.
Protobuf First
Auto-generated .proto files with deep field validation and secure gRPC-Gateway metadata definitions.
Kratos secured
OIDC/JWT authentication interceptors baked directly into the Kratos middleware for every generated gRPC service.
The Protobuf Lifecycle
// Generated Service Schema for Entity
service EntityService {
rpc Get (GetEntityRequest) returns (EntityReply) {
option (google.api.http) = {
get: "/v1/entity/{id}"
};
}
}
Compiling Protobuf & gRPC Contracts
GO-DUCK scaffolds script files in the root of the generated project to manage the compilation of .proto contracts natively on all operating systems.
⚡ Execution Requirement Guide
- Local Host Execution (Required): You must run the compilation script whenever you first create the microservice, or whenever you modify the GDL schemas and re-run
import-gdlto generate updated gRPC structures. - Docker Deployment (Automated): If you compile and run the application via Docker (using
docker buildordocker-compose), the multi-stagedevops/Dockerfilecompiles the protobuf definitions internally, so you do not need to run the scripts locally.
🛠️ Scaffolded Compiler Scripts
The generator scaffolds both generate.sh and generate.bat files in the project root. At compilation time, they perform the following tasks:
- Create the
third_party/google/apidependencies directory. - Synchronize necessary Google API annotation contracts (
annotations.protoandhttp.proto) using native command line transfers. - Recursively find and compile all
.protofiles insideapi/into Go source files using theprotoccompiler.
🚀 How to Compile
To compile the contract schemas into Go source structures, execute the following commands in the root of your generated application:
.\generate.bat
chmod +x generate.sh
./generate.sh
📌 Compilation Prerequisites
Ensure you have the protoc binary installed and added to your system's PATH.
Also ensure the necessary Go compiler plugins are installed on your environment:
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
Federated gRPC Resolution
Our gRPC implementation is natively silo-aware. It uses the same Repository Layer as the REST controllers—ensuring that every RPC call is routed to the correct database silo based on the caller's JWT role.