liveBook · Manning

Client interceptor

As explained in gRPC Microservices in Go

A client-side RPC component that modifies or enriches a request before it reaches the server.

A client interceptor is a gRPC component that modifies or enriches a request before it reaches the server. It provides a central place to apply cross-cutting client-side behavior, such as circuit-breaker logic, instead of wrapping every dependent-service call separately. section 6.1.3

A circuit-breaker client interceptor typically:

  • Accepts a circuit breaker and returns a grpc.UnaryClientInterceptor. section 6.1.3
  • Applies the behavior at client connection setup so calls to an unavailable service fail through the breaker rather than being sent blindly. section 6.1.3

Protecting order creation

An order client invokes Create through a circuit breaker. The interceptor generalizes that protection: it executes each unary RPC through gobreaker and returns the resulting error to the caller.

How gRPC Microservices in Go covers it

How deep it goes
Explains the interceptor boundary and implements unary invocation through a circuit breaker, without detailing interceptor registration fully.
Examples
Uses periodic order creation, gobreaker, and a Go UnaryClientInterceptor wrapping the RPC invoker.
What it assumes
Assumes familiarity with gRPC client calls, UnaryClientInterceptor, RPC invokers, and circuit-breaker behavior.
What you can do after
Build it from scratch as a Go gRPC interceptor that routes unary calls through gobreaker.
How it connects
Connects gRPC, circuit breaker pattern, retry operation, server interceptors, and resilient communication.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of gRPC Microservices in Go. The section links point to the parts of the book it draws on.