modshared

package
v19.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// EnvVarPodNamespace is the environment variable that holds the namespace of the Pod the program runs in.
	EnvVarPodNamespace = "POD_NAMESPACE"
	// EnvVarPodName is the environment variable that holds the name of the Pod the program runs in.
	EnvVarPodName = "POD_NAME"
	// EnvVarServiceAccountName is the environment variable that holds the name of the ServiceAccount
	// the program runs as.
	EnvVarServiceAccountName = "SERVICE_ACCOUNT_NAME"
)

Variables

View Source
var (
	NoAgentKey = api.AgentKey{ID: 0, Type: api.AgentTypeUnknown}
)

Functions

func InjectRPCAPI

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

func RPCAPIFromContext

func RPCAPIFromContext[T RPCAPI](ctx context.Context) T

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 {
	errz.ErrReporter
}

API provides the API for the module to use.

type Factory

type Factory interface {
	// Name returns module's name.
	Name() string
}

type RPCAPI

type RPCAPI interface {
	errz.ErrReporter
	// Log returns a logger to use in the context of the request being processed.
	Log() *slog.Logger
	// 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, opts ...retry.PollOption) error
}

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

type RPCAPIFactory

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

type RPCAPIStub

type RPCAPIStub struct {
	StreamCtx context.Context //nolint:containedctx
	Logger    *slog.Logger
}

func (*RPCAPIStub) Log

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

func (*RPCAPIStub) PollWithBackoff

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

Jump to

Keyboard shortcuts

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