examples

module
v0.0.0-...-c63aeef Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 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
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
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
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
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
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
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
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
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
Binary client demonstrates how to specify compression options when performing RPCs.
Binary client demonstrates how to specify compression options when performing RPCs.
compression/server
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
Binary client is a client for the CSM Observability example.
Binary client is a client for the CSM Observability example.
csm_observability/server
Binary server is a server for the CSM Observability example.
Binary server is a server for the CSM Observability example.
customloadbalancer/client
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
Binary server is a server for the custom load balancer example.
Binary server is a server for the custom load balancer example.
deadline/client
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
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
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
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.
encryption/ALTS/client
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
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
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
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
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
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
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
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
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
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
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
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.
health/client
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
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
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
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
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
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
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
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
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
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
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
Binary server demonstrates how to update metadata from interceptors on server.
Binary server demonstrates how to update metadata from interceptors on server.
multiplex/client
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
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
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
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
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
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
Binary client is a client for the OpenTelemetry example.
Binary client is a client for the OpenTelemetry example.
opentelemetry/server
Binary server is a server for the OpenTelemetry example.
Binary server is a server for the OpenTelemetry example.
orca/client
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
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
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
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
Binary server demonstrates to enforce retries on client side.
Binary server demonstrates to enforce retries on client side.
stats_monitoring/client
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
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
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
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
Binary wait_for_ready is an example for "wait for ready".
Binary wait_for_ready is an example for "wait for ready".
xds/client
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
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
Package main implements a client for Greeter service.
Package main implements a client for Greeter service.
greeter_server
Package main implements a server for Greeter service.
Package main implements a server for Greeter service.
route_guide
client
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
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