Documentation
¶
Index ¶
- Variables
- func APIToErrReporter(api API) errz.ErrReporter
- func InjectRPCAPI(ctx context.Context, rpcAPI RPCAPI) context.Context
- func RPCAPIFromContext[T RPCAPI](ctx context.Context) T
- func StreamRPCAPIInterceptor(factory RPCAPIFactory) grpc.StreamServerInterceptor
- func UnaryRPCAPIInterceptor(factory RPCAPIFactory) grpc.UnaryServerInterceptor
- type API
- type Factory
- type RPCAPI
- type RPCAPIFactory
- type RPCAPIStub
Constants ¶
This section is empty.
Variables ¶
View Source
var (
NoAgentKey = api.AgentKey{ID: 0, Type: api.AgentTypeUnknown}
)
Functions ¶
func APIToErrReporter ¶
func APIToErrReporter(api API) errz.ErrReporter
func RPCAPIFromContext ¶
func StreamRPCAPIInterceptor ¶
func StreamRPCAPIInterceptor(factory RPCAPIFactory) grpc.StreamServerInterceptor
StreamRPCAPIInterceptor returns a new stream server interceptor that augments connection context with a RPCAPI.
func UnaryRPCAPIInterceptor ¶
func UnaryRPCAPIInterceptor(factory RPCAPIFactory) grpc.UnaryServerInterceptor
UnaryRPCAPIInterceptor returns a new unary server interceptor that augments connection context with a RPCAPI.
Types ¶
type API ¶
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 *slog.Logger, msg string, err error, fields ...fieldz.Field)
}
API provides the API for the module to use.
type RPCAPI ¶
type RPCAPI interface {
// Log returns a logger to use in the context of the request being processed.
Log() *slog.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 *slog.Logger, msg string, err error, fields ...fieldz.Field)
// 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 *slog.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 canceled 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.
type RPCAPIStub ¶
func (*RPCAPIStub) Log ¶
func (a *RPCAPIStub) Log() *slog.Logger
func (*RPCAPIStub) PollWithBackoff ¶
func (a *RPCAPIStub) PollWithBackoff(cfg retry.PollConfig, f retry.PollWithBackoffFunc) error
Click to show internal directories.
Click to hide internal directories.