interceptor

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package interceptor defines gRPC interceptors for Trillian.

Index

Constants

This section is empty.

Variables

View Source
var (
	// PutTokensTimeout is the timeout used for PutTokens calls.
	// PutTokens happens in a separate goroutine and with an independent context, therefore it has
	// its own timeout, separate from the RPC that causes the calls.
	PutTokensTimeout = 5 * time.Second
)

Functions

func Combine

func Combine(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor

Combine combines unary interceptors. They are nested in order, so interceptor[0] calls on to (and sees the result of) interceptor[1], etc.

func ErrorWrapper

func ErrorWrapper(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

ErrorWrapper is a grpc.UnaryServerInterceptor that wraps the errors emitted by the underlying handler.

Types

type RequestProcessor

type RequestProcessor interface {

	// Before implements all interceptor logic that happens before the handler is called.
	// It returns a (potentially) modified context that's passed forward to the handler (and After),
	// plus an error, in case the request should be interrupted before the handler is invoked.
	Before(ctx context.Context, req interface{}) (context.Context, error)

	// After implements all interceptor logic that happens after the handler is invoked.
	// Before must be invoked prior to After and the same RequestProcessor instance must to be used
	// to process a given request.
	After(ctx context.Context, resp interface{}, handlerErr error)
}

RequestProcessor encapsulates the logic to intercept a request, split into separate stages: before and after the handler is invoked.

type TrillianInterceptor

type TrillianInterceptor struct {
	// contains filtered or unexported fields
}

TrillianInterceptor checks that: * Requests addressing a tree have the correct tree type and tree state; * TODO(codingllama): Requests are properly authenticated / authorized ; and * Requests are rate limited appropriately.

func New

New returns a new TrillianInterceptor instance.

func (*TrillianInterceptor) NewProcessor

func (i *TrillianInterceptor) NewProcessor() RequestProcessor

NewProcessor returns a RequestProcessor for the TrillianInterceptor logic.

func (*TrillianInterceptor) UnaryInterceptor

func (i *TrillianInterceptor) UnaryInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

UnaryInterceptor executes the TrillianInterceptor logic for unary RPCs.

Jump to

Keyboard shortcuts

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