modserver

package
v16.8.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RoutingHopPrefix is a metadata key prefix that is used for metadata keys that should be consumed by
	// the gateway kas instances and not passed along to agentk.
	RoutingHopPrefix = "kas-hop-"
	// RoutingAgentIdMetadataKey is used to pass destination agent id in request metadata
	// from the routing kas instance, that is handling the incoming request, to the gateway kas instance,
	// that is forwarding the request to an agentk.
	RoutingAgentIdMetadataKey = RoutingHopPrefix + "routing-agent-id"

	// SentryFieldTraceId is the name of the Sentry field for trace ID.
	SentryFieldTraceId      = "trace_id"
	SentryFieldTraceSampled = "trace_sampled"
	GrpcServiceSentryField  = "grpc.service"
	GrpcMethodSentryField   = "grpc.method"
)

Variables

This section is empty.

Functions

func InjectAgentRpcApi

func InjectAgentRpcApi(ctx context.Context, rpcApi AgentRpcApi) context.Context

func InjectRpcApi

func InjectRpcApi(ctx context.Context, rpcApi RpcApi) context.Context

func StreamAgentRpcApiInterceptor

func StreamAgentRpcApiInterceptor(factory AgentRpcApiFactory) grpc.StreamServerInterceptor

StreamAgentRpcApiInterceptor returns a new stream server interceptor that augments connection context with a AgentRpcApi.

func StreamRpcApiInterceptor

func StreamRpcApiInterceptor(factory RpcApiFactory) grpc.StreamServerInterceptor

StreamRpcApiInterceptor returns a new stream server interceptor that augments connection context with a RpcApi.

func UnaryAgentRpcApiInterceptor

func UnaryAgentRpcApiInterceptor(factory AgentRpcApiFactory) grpc.UnaryServerInterceptor

UnaryAgentRpcApiInterceptor returns a new unary server interceptor that augments connection context with a AgentRpcApi.

func UnaryRpcApiInterceptor

func UnaryRpcApiInterceptor(factory RpcApiFactory) grpc.UnaryServerInterceptor

UnaryRpcApiInterceptor returns a new unary server interceptor that augments connection context with a RpcApi.

Types

type AgentRpcApi

type AgentRpcApi interface {
	modshared.RpcApi
	// AgentToken returns the token of an agent making the RPC.
	AgentToken() api.AgentToken
	// AgentInfo returns information about the agent making the RPC.
	// Returns a gRPC-compatible error.
	// Returns an error with the Unavailable code if there was a retriable error.
	// If there was an error, it takes care of tracking it via HandleProcessingError().
	AgentInfo(ctx context.Context, log *zap.Logger) (*api.AgentInfo, error)
}

AgentRpcApi provides the API for the module's gRPC handlers to use. It should be used only by modules, that handle requests from agents.

func AgentRpcApiFromContext

func AgentRpcApiFromContext(ctx context.Context) AgentRpcApi

type AgentRpcApiFactory

type AgentRpcApiFactory func(ctx context.Context, fullMethodName string) (AgentRpcApi, error)

type Api

type Api interface {
	modshared.Api
	// OnGitPushEvent runs the given callback function for a received git push event.
	// The git push event may come from any GitLab project and as such it's up to the
	// callback to filter out the events that it's interested in.
	// The callback MUST NOT block i.e. perform I/O or acquire contended locks. Perform those operations
	// asynchronously in a separate goroutine when required.
	OnGitPushEvent(ctx context.Context, cb syncz.EventCallback[*event.GitPushEvent])
}

Api provides the API for the module to use.

type ApplyDefaults

type ApplyDefaults func(*kascfg.ConfigurationFile)

ApplyDefaults is a signature of a public function, exposed by modules to perform defaulting. The function should be called ApplyDefaults.

type Config

type Config struct {
	// Log can be used for logging from the module.
	// It should not be used for logging from gRPC Api methods. Use grpctool.LoggerFromContext(ctx) instead.
	Log          *zap.Logger
	Api          Api
	Config       *kascfg.ConfigurationFile
	GitLabClient gitlab.ClientInterface
	UsageTracker usage_metrics.UsageTrackerRegisterer
	EventTracker event_tracker.EventTrackerRegisterer
	// AgentServer is the gRPC server agentk is talking to.
	// This can be used to add endpoints in Factory.New.
	// Request handlers can obtain the per-request logger using grpctool.LoggerFromContext(requestContext).
	AgentServer *grpc.Server
	// ApiServer is the gRPC server GitLab is talking to.
	// This can be used to add endpoints in Factory.New.
	// Request handlers can obtain the per-request logger using grpctool.LoggerFromContext(requestContext).
	ApiServer *grpc.Server
	// RegisterAgentApi allows to register a gRPC Api endpoint that kas proxies to agentk.
	RegisterAgentApi func(*grpc.ServiceDesc)
	// AgentConn is a gRPC connection that can be used to send requests to an agentk instance.
	// Agent Id must be specified in the request metadata in RoutingAgentIdMetadataKey field.
	// Make sure factory returns modshared.ModuleStartAfterServers if module uses this connection.
	AgentConn       grpc.ClientConnInterface
	Gitaly          gitaly.PoolInterface
	TraceProvider   trace.TracerProvider
	TracePropagator propagation.TextMapPropagator
	MeterProvider   otelmetric.MeterProvider
	Meter           otelmetric.Meter
	RedisClient     rueidis.Client
	// KasName is a string "gitlab-kas". Can be used as a user agent, server name, service name, etc.
	KasName string
	// Version is gitlab-kas version.
	Version string
	// CommitId is gitlab-kas commit sha.
	CommitId string
	// ProbeRegistry is for registering liveness probes and readiness probes
	ProbeRegistry *observability.ProbeRegistry
}

Config holds configuration for a Module.

type Factory

type Factory interface {
	modshared.Factory
	// New creates a new instance of a Module.
	New(*Config) (Module, error)
}

type Module

type Module interface {
	// Run starts the module.
	// Run can block until the context is canceled or exit with nil if there is nothing to do.
	Run(context.Context) error
	// Name returns module's name.
	Name() string
}

type RpcApi

type RpcApi interface {
	modshared.RpcApi
}

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

func RpcApiFromContext

func RpcApiFromContext(ctx context.Context) RpcApi

type RpcApiFactory

type RpcApiFactory func(ctx context.Context, fullMethodName string) RpcApi

Jump to

Keyboard shortcuts

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