examples

module
v0.0.0-...-5ccc418 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2025 License: Apache-2.0

README

Examples

The following examples are provided to help users get started with gRPC-Go. They are arranged as follows:

  • helloworld - a simple example showing a basic client and server
  • routeguide - a more complicated example showing different types of streaming RPCs
  • features - a collection of examples, each focused on a single gRPC feature

data is a directory containing data used by the examples, e.g. TLS certificates.

Directories

Path Synopsis
Package data provides convenience routines to access files in the data directory.
Package data provides convenience routines to access files in the data directory.
features
advancedtls/client command
Binary client is an example client demonstrating use of advancedtls, to set up a secure gRPC client connection with various TLS authentication methods.
Binary client is an example client demonstrating use of advancedtls, to set up a secure gRPC client connection with various TLS authentication methods.
advancedtls/server command
Binary server is an example client demonstrating how to set up a secure gRPC server using advancedtls.
Binary server is an example client demonstrating how to set up a secure gRPC server using advancedtls.
authentication/client command
The client demonstrates how to supply an OAuth2 token for every RPC.
The client demonstrates how to supply an OAuth2 token for every RPC.
authentication/server command
The server demonstrates how to consume and validate OAuth2 tokens provided by clients for each RPC.
The server demonstrates how to consume and validate OAuth2 tokens provided by clients for each RPC.
authz/client command
Binary client demonstrates how to include authorization credentials in the form of metadata in every RPC for server side validation.
Binary client demonstrates how to include authorization credentials in the form of metadata in every RPC for server side validation.
authz/server command
Binary server demonstrates how to validate authorization credential metadata for incoming RPCs.
Binary server demonstrates how to validate authorization credential metadata for incoming RPCs.
authz/token
Package token implements an example of authorization token encoding/decoding that can be used in RPC headers.
Package token implements an example of authorization token encoding/decoding that can be used in RPC headers.
cancellation/client command
Binary client demonstrates how to cancel in-flight RPCs by canceling the context passed to the RPC.
Binary client demonstrates how to cancel in-flight RPCs by canceling the context passed to the RPC.
cancellation/server command
Binary server demonstrates how to handle canceled contexts when a client cancels an in-flight RPC.
Binary server demonstrates how to handle canceled contexts when a client cancels an in-flight RPC.
compression/client command
Binary client demonstrates how to specify compression options when performing RPCs.
Binary client demonstrates how to specify compression options when performing RPCs.
compression/server command
Binary server demonstrates how to install and support compressors for incoming RPCs.
Binary server demonstrates how to install and support compressors for incoming RPCs.
csm_observability/client command
Binary client is a client for the CSM Observability example.
Binary client is a client for the CSM Observability example.
csm_observability/server command
Binary server is a server for the CSM Observability example.
Binary server is a server for the CSM Observability example.
customloadbalancer/client command
Binary client is a client for the custom load balancer example.
Binary client is a client for the custom load balancer example.
customloadbalancer/client/customroundrobin
Package customroundrobin provides an example for the custom roundrobin balancer.
Package customroundrobin provides an example for the custom roundrobin balancer.
customloadbalancer/server command
Binary server is a server for the custom load balancer example.
Binary server is a server for the custom load balancer example.
deadline/client command
Binary client demonstrates how to set deadlines for RPCs and how to handle deadline-exceeded errors.
Binary client demonstrates how to set deadlines for RPCs and how to handle deadline-exceeded errors.
deadline/server command
Binary server demonstrates how to handle RPCs with deadlines and how to propagate deadlines in requests.
Binary server demonstrates how to handle RPCs with deadlines and how to propagate deadlines in requests.
debugging/client command
Binary client demonstrates how to use logging and Channelz for debugging gRPC operations.
Binary client demonstrates how to use logging and Channelz for debugging gRPC operations.
debugging/server command
Binary server demonstrates how to enable logging and Channelz for debugging gRPC services.
Binary server demonstrates how to enable logging and Channelz for debugging gRPC services.
dualstack/client command
Binary client is a client for the dualstack example.
Binary client is a client for the dualstack example.
dualstack/server command
Binary server is a server for the dualstack example.
Binary server is a server for the dualstack example.
encryption/ALTS/client command
Binary client demonstrates how to use ALTS credentials for secure gRPC communication.
Binary client demonstrates how to use ALTS credentials for secure gRPC communication.
encryption/ALTS/server command
Binary server demonstrates how to use ALTS credentials to secure gRPC services.
Binary server demonstrates how to use ALTS credentials to secure gRPC services.
encryption/TLS/client command
Binary client demonstrates how to use TLS credentials for secure gRPC communication.
Binary client demonstrates how to use TLS credentials for secure gRPC communication.
encryption/TLS/server command
Binary server demonstrates how to use TLS credentials to secure gRPC services.
Binary server demonstrates how to use TLS credentials to secure gRPC services.
encryption/mTLS/client command
Binary client is an example client which connects to the server using mTLS.
Binary client is an example client which connects to the server using mTLS.
encryption/mTLS/server command
Binary server is an example server which authenticates clients using mTLS.
Binary server is an example server which authenticates clients using mTLS.
error_details/client command
Binary client demonstrates how to handle error messages from a gRPC server.
Binary client demonstrates how to handle error messages from a gRPC server.
error_details/server command
Binary server demonstrates how to provide error messages in gRPC responses.
Binary server demonstrates how to provide error messages in gRPC responses.
error_handling/client command
Binary client demonstrates how to handle errors returned by a gRPC server.
Binary client demonstrates how to handle errors returned by a gRPC server.
error_handling/server command
Binary server demonstrates how to return specific error codes in gRPC responses.
Binary server demonstrates how to return specific error codes in gRPC responses.
flow_control/client command
Binary client demonstrates how the gRPC flow control blocks sending when the receiver is not ready.
Binary client demonstrates how the gRPC flow control blocks sending when the receiver is not ready.
flow_control/server command
Binary server demonstrates how gRPC flow control block sending when the receiver is not ready.
Binary server demonstrates how gRPC flow control block sending when the receiver is not ready.
gracefulstop/client command
Binary client demonstrates sending multiple requests to server and observe graceful stop.
Binary client demonstrates sending multiple requests to server and observe graceful stop.
gracefulstop/server command
Binary server demonstrates how to gracefully stop a gRPC server.
Binary server demonstrates how to gracefully stop a gRPC server.
health/client command
Binary client demonstrates how to check and observe gRPC server health using the health library.
Binary client demonstrates how to check and observe gRPC server health using the health library.
health/server command
Binary server demonstrates how to manage and report its health status using the gRPC health library.
Binary server demonstrates how to manage and report its health status using the gRPC health library.
interceptor/client command
Binary client demonstrates how to use interceptors to observe or control the behavior of gRPC including logging, authentication,metrics collection, etc.
Binary client demonstrates how to use interceptors to observe or control the behavior of gRPC including logging, authentication,metrics collection, etc.
interceptor/server command
Binary server demonstrates how to use interceptors to observe or control the behavior of gRPC including logging, authentication,metrics collection, etc.
Binary server demonstrates how to use interceptors to observe or control the behavior of gRPC including logging, authentication,metrics collection, etc.
keepalive/client command
Binary client demonstrates how to configure keepalive pings to maintain connectivity and detect stale connections.
Binary client demonstrates how to configure keepalive pings to maintain connectivity and detect stale connections.
keepalive/server command
Binary server demonstrates how to enforce keepalive settings and manage idle connections to maintain active client connections.
Binary server demonstrates how to enforce keepalive settings and manage idle connections to maintain active client connections.
load_balancing/client command
Binary client demonstrates how to configure load balancing policies to distribute RPCs across backend servers.
Binary client demonstrates how to configure load balancing policies to distribute RPCs across backend servers.
load_balancing/server command
Binary server demonstrates how to spin up multiple server backends to enable client-side load balancing.
Binary server demonstrates how to spin up multiple server backends to enable client-side load balancing.
metadata/client command
Binary client demonstrates how to send and receive metadata to and from an RPC.
Binary client demonstrates how to send and receive metadata to and from an RPC.
metadata/server command
Binary server demonstrates how to send and read metadata to and from RPC.
Binary server demonstrates how to send and read metadata to and from RPC.
metadata_interceptor/client command
Binary client demonstrates how to receive metadata in RPC headers and trailers.
Binary client demonstrates how to receive metadata in RPC headers and trailers.
metadata_interceptor/server command
Binary server demonstrates how to update metadata from interceptors on server.
Binary server demonstrates how to update metadata from interceptors on server.
multiplex/client command
Binary client demonstrates how to use a single grpc.ClientConn for multiple service stubs.
Binary client demonstrates how to use a single grpc.ClientConn for multiple service stubs.
multiplex/server command
Binary server demonstrates how to use a single grpc.Server instance to register and serve multiple services.
Binary server demonstrates how to use a single grpc.Server instance to register and serve multiple services.
name_resolving/client command
Binary client demonstrates how to use custom name resolvers to resolve server backend addresses.
Binary client demonstrates how to use custom name resolvers to resolve server backend addresses.
name_resolving/server command
Binary server demonstrates how to set up a gRPC server that listens on a specified port for name resolution examples.
Binary server demonstrates how to set up a gRPC server that listens on a specified port for name resolution examples.
observability/client command
Binary client demonstrates how to instrument RPCs with logging, metrics, and tracing.
Binary client demonstrates how to instrument RPCs with logging, metrics, and tracing.
observability/server command
Binary server demonstrates how to instrument RPCs for logging, metrics, and tracing.
Binary server demonstrates how to instrument RPCs for logging, metrics, and tracing.
opentelemetry/client command
Binary client is a client for the OpenTelemetry example.
Binary client is a client for the OpenTelemetry example.
opentelemetry/server command
Binary server is a server for the OpenTelemetry example.
Binary server is a server for the OpenTelemetry example.
orca/client command
Binary client demonstrates the use of a custom LB policy that handles ORCA per-call and out-of-band metrics for load reporting.
Binary client demonstrates the use of a custom LB policy that handles ORCA per-call and out-of-band metrics for load reporting.
orca/server command
Binary server demonstrates how to use ORCA for reporting out-of-band and per-RPC load metrics.
Binary server demonstrates how to use ORCA for reporting out-of-band and per-RPC load metrics.
reflection/server command
Binary server demonstrates how to register multiple services and enable client discovery.
Binary server demonstrates how to register multiple services and enable client discovery.
retry/client command
Binary client demonstrates how to enable and configure retry policies for gRPC requests.
Binary client demonstrates how to enable and configure retry policies for gRPC requests.
retry/server command
Binary server demonstrates to enforce retries on client side.
Binary server demonstrates to enforce retries on client side.
stats_monitoring/client command
Binary client is an example client to illustrate the use of the stats handler.
Binary client is an example client to illustrate the use of the stats handler.
stats_monitoring/server command
Binary server is an example server to illustrate the use of the stats handler.
Binary server is an example server to illustrate the use of the stats handler.
stats_monitoring/statshandler
Package statshandler is an example pkg to illustrate the use of the stats handler.
Package statshandler is an example pkg to illustrate the use of the stats handler.
unix_abstract/client command
Binary client is an example client which dials a server on an abstract unix socket.
Binary client is an example client which dials a server on an abstract unix socket.
unix_abstract/server command
Binary server is an example server listening for gRPC connections on an abstract unix socket.
Binary server is an example server listening for gRPC connections on an abstract unix socket.
wait_for_ready command
Binary wait_for_ready is an example for "wait for ready".
Binary wait_for_ready is an example for "wait for ready".
xds/client command
Binary main implements a client for Greeter service using gRPC's client-side support for xDS APIs.
Binary main implements a client for Greeter service using gRPC's client-side support for xDS APIs.
xds/server command
Binary server demonstrated gRPC's support for xDS APIs on the server-side.
Binary server demonstrated gRPC's support for xDS APIs on the server-side.
observability module
greeter_client command
Package main implements a client for Greeter service.
Package main implements a client for Greeter service.
greeter_server command
Package main implements a server for Greeter service.
Package main implements a server for Greeter service.
route_guide
client command
Package main implements a simple gRPC client that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
Package main implements a simple gRPC client that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
server command
Package main implements a simple gRPC server that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
Package main implements a simple gRPC server that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL