gRPC Client
pkg/grpc/client establishes a gRPC connection and registers a typed client in DI via WithClient.
Pass WithClient a proto-generated constructor (func(*grpc.ClientConn) T). The typed client is registered directly in DI — no need to ever handle the raw connection.
lakta.NewRuntime( config.NewModule( config.WithConfigDirs(".", "./config"), config.WithArgs(os.Args[1:]), ), tint.NewModule(), slog.NewModule(), otel.NewModule(), grpcclient.NewModule( grpcclient.WithName("data"), grpcclient.WithClient(v1.NewDataServiceClient), ), grpcclient.NewModule( grpcclient.WithName("orchestrator"), grpcclient.WithClient(v1.NewWorkflowServiceClient), ), myapp.NewModule(),)Consuming the client
Section titled “Consuming the client”Use lakta.Invoke[T](ctx) in any handler. The typed interface is what was registered — not the raw *grpc.ClientConn.
// gRPC handlerfunc (s *MyServer) PlaceOrder(ctx context.Context, req *pb.PlaceOrderRequest) (*pb.PlaceOrderResponse, error) { dataClient, err := lakta.Invoke[v1.DataServiceClient](ctx) if err != nil { return nil, err } return dataClient.CreateOrder(ctx, &v1.CreateOrderRequest{...})}
// HTTP handler (Fiber)func handlePost(c fiber.Ctx) error { client, err := lakta.Invoke[v1.DataServiceClient](c.Context()) if err != nil { return err } resp, err := client.GetThing(c.Context(), &v1.GetThingRequest{Id: c.Params("id")}) ...}Multiple connections
Section titled “Multiple connections”Each instance needs a name and its own config block:
grpcclient.NewModule( grpcclient.WithName("data"), grpcclient.WithClient(v1.NewDataServiceClient),),grpcclient.NewModule( grpcclient.WithName("orchestrator"), grpcclient.WithClient(v1.NewWorkflowServiceClient),),modules: grpc: client: data: target: "data-svc:50051" insecure: true orchestrator: target: "orchestrator-svc:50052" insecure: trueSee Multi-instance Modules for the full pattern.
Configuration Reference
Section titled “Configuration Reference”Config path: modules.grpc.client.<name>
target target specifies the target address for the gRPC client connection
LAKTA_MODULES_GRPC_CLIENT_<NAME>_TARGET insecure insecure determines whether transport credentials should use an insecure configuration
LAKTA_MODULES_GRPC_CLIENT_<NAME>_INSECURE Code-only options
Section titled “Code-only options”These options can only be set in Go code via With*() functions, not via config files or environment variables.
| Option | Type | Description |
|---|---|---|
Credentials(...) | credentials.TransportCredentials | |
WithClient(...) | []client.ClientRegistrar | registers a typed client constructor (code-only) |