modshared

package
v16.9.11 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoAgentID int64 = 0
)

Variables

This section is empty.

Functions

func APIToErrReporter added in v16.9.0

func APIToErrReporter(api API) errz.ErrReporter

func InjectRPCAPI added in v16.9.0

func InjectRPCAPI(ctx context.Context, rpcAPI RPCAPI) context.Context

func StreamRPCAPIInterceptor added in v16.9.0

func StreamRPCAPIInterceptor(factory RPCAPIFactory) grpc.StreamServerInterceptor

StreamRPCAPIInterceptor returns a new stream server interceptor that augments connection context with a RPCAPI.

func UnaryRPCAPIInterceptor added in v16.9.0

func UnaryRPCAPIInterceptor(factory RPCAPIFactory) grpc.UnaryServerInterceptor

UnaryRPCAPIInterceptor returns a new unary server interceptor that augments connection context with a RPCAPI.

Types

type API added in v16.9.0

type API interface {
	// HandleProcessingError can be used to handle errors occurring while processing a request.
	// If err is a (or wraps a) errz.UserError, it might be handled specially.
	HandleProcessingError(ctx context.Context, log *zap.Logger, agentID int64, msg string, err error)
}

API provides the API for the module to use.

type Factory

type Factory interface {
	// Name returns module's name.
	Name() string
	// StartStopPhase defines when to start and stop module during the program lifecycle.
	StartStopPhase() ModuleStartStopPhase
}

type ModuleStartStopPhase

type ModuleStartStopPhase byte
const (
	ModuleStartBeforeServers ModuleStartStopPhase
	ModuleStartAfterServers
)

type RPCAPI added in v16.9.0

type RPCAPI interface {
	// Log returns a logger to use in the context of the request being processed.
	Log() *zap.Logger
	// HandleProcessingError can be used to handle errors occurring while processing a request.
	// If err is a (or wraps a) errz.UserError, it might be handled specially.
	HandleProcessingError(log *zap.Logger, agentID int64, msg string, err error)
	// HandleIoError can be used to handle I/O error produced by gRPC Send(), Recv() methods or any other I/O error.
	// It returns an error, compatible with gRPC status package.
	HandleIoError(log *zap.Logger, msg string, err error) error
	// PollWithBackoff runs f every duration given by BackoffManager.
	//
	// PollWithBackoff should be used by the top-level polling, so that it can be gracefully interrupted
	// by the server when necessary. E.g. when stream is nearing it's max connection age or program needs to
	// be shut down.
	// If sliding is true, the period is computed after f runs. If it is false then
	// period includes the runtime for f.
	// It returns when:
	// - stream's context is cancelled or max connection age has been reached. nil is returned in this case.
	// - f returns Done. error from f is returned in this case.
	PollWithBackoff(cfg retry.PollConfig, f retry.PollWithBackoffFunc) error
}

RPCAPI provides the API for the module's gRPC handlers to use.

func RPCAPIFromContext added in v16.9.0

func RPCAPIFromContext(ctx context.Context) RPCAPI

type RPCAPIFactory added in v16.9.0

type RPCAPIFactory func(ctx context.Context, method string) RPCAPI

type RPCAPIStub added in v16.9.0

type RPCAPIStub struct {
	StreamCtx context.Context
	Logger    *zap.Logger
}

func (*RPCAPIStub) Log added in v16.9.0

func (a *RPCAPIStub) Log() *zap.Logger

func (*RPCAPIStub) PollWithBackoff added in v16.9.0

func (a *RPCAPIStub) PollWithBackoff(cfg retry.PollConfig, f retry.PollWithBackoffFunc) error

Jump to

Keyboard shortcuts

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