Documentation
¶
Overview ¶
Package client contains the client-side gRPC Interceptor for Unary RPC calls, intended for use in a caching reverse proxy implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachingInterceptor ¶
type CachingInterceptor interface { // UnaryServerInterceptor creates the server interceptor part of the // reverse proxy. UnaryServerInterceptor() grpc.UnaryServerInterceptor // UnaryClientInterceptor creates the client interceptor part of the // reverse proxy. UnaryClientInterceptor() grpc.UnaryClientInterceptor }
A CachingInterceptor intercepts incoming calls to a reverse proxy's server part, and outgoing calls from the reverse proxy's client part. It should, by contract, cache the responses.
type InmemoryCachingInterceptor ¶
type InmemoryCachingInterceptor struct {
Cache cache.Cache
}
InmemoryCachingInterceptor is an implementation of CachingInterceptor, which uses an in-memory cache to store objects.
func (*InmemoryCachingInterceptor) UnaryClientInterceptor ¶
func (interceptor *InmemoryCachingInterceptor) UnaryClientInterceptor() grpc.UnaryClientInterceptor
UnaryClientInterceptor catches outgoing calls, and inspects the response headers on the incoming response. If cache headers are set, the response is cached in the in-memory cache for as long as the header specifies. Subsequent matching operation invocations via the reverse proxy that uses these Interceptors will therefore be served from cache.
func (*InmemoryCachingInterceptor) UnaryServerInterceptor ¶
func (interceptor *InmemoryCachingInterceptor) UnaryServerInterceptor(csvLog *log.Logger) grpc.UnaryServerInterceptor
UnaryServerInterceptor catches all incoming calls, verifies if a suitable response is already in cache, and if so, it just responds with it. If no such response is found, the call is allowed to continue as usual, via a client call (which should be intercepted also).