Skip to content

grpcclient

A light, framework-free gRPC client dial factory — build a *grpc.ClientConn from a plain Target (host, port and go/tls material), with the go/transit client interceptors passed straight through as dial options.

go get gitlab.com/phpboyscout/go/grpcclient

gitlab.com/phpboyscout/go/grpcclient gives a service or library a gRPC client with project-standard TLS defaults and no framework in tow. Dial(Target{…}) returns a stock *grpc.ClientConn: transport credentials are selected from the target's go/tls pair (insecure when disabled, hardened TLS when enabled), the endpoint is assembled from host and port, and the caller's dial options are applied. It is the gRPC client half of the transport stack extracted from go-tool-base.

What it does

  • Framework-free. The module requires only the gRPC SDK, go/tls and cockroachdb/errors. A depfootprint_test.go guard forbids go-tool-base, the server stack, and the cloud, CLI and TUI stacks — so a client-only consumer never inherits any of them.
  • Decoupled Target. The dial factory takes a first-class Target{Host, Port, TLS}, not a server-settings type, so a client never imports server configuration.
  • The interceptors are transit's. Circuit breaking and OpenTelemetry instrumentation are the go/transit gRPC client interceptors; you pass them to Dial as ordinary grpc.DialOptions. Transit is not a dependency of this module — add it to your own go.mod when you want it.

What it does not do

Dial will not do mutual TLS, will not validate a Target, will not retry, will not pool connections, and will not stop a caller's dial option from replacing the credentials it derived. Those are deliberate boundaries or known sharp edges rather than gaps waiting to be filled — What grpcclient does not do states each one and what to use instead.

Where next


Part of the phpboyscout Go toolkit — small, framework-free Go modules extracted from go-tool-base.

Further reading

The blog carries a curated route through this subject: Building a web service in Go collects everything written about it, ordered so you can start at the beginning rather than newest-first.

Ask phpbotscout

phpbotscout

He answers questions about the projects over on the Discord, citing the docs where they already cover it, and offering to raise an issue where they don't. Bring a bug, an idea, or a questionable engineering decision.

Join the Discord