Documentation ¶
Index ¶
- Constants
- func InjectAgentRPCAPI(ctx context.Context, rpcAPI AgentRPCAPI) context.Context
- func StreamAgentRPCAPIInterceptor(factory AgentRPCAPIFactory) grpc.StreamServerInterceptor
- func UnaryAgentRPCAPIInterceptor(factory AgentRPCAPIFactory) grpc.UnaryServerInterceptor
- type API
- type AgentInfoResolver
- type AgentRPCAPI
- type AgentRPCAPIFactory
- type ApplyDefaults
- type Config
- type Factory
- type Module
Constants ¶
View Source
const ( // 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 StreamAgentRPCAPIInterceptor ¶
func StreamAgentRPCAPIInterceptor(factory AgentRPCAPIFactory) grpc.StreamServerInterceptor
StreamAgentRPCAPIInterceptor returns a new stream server interceptor that augments connection context with a AgentRPCAPI.
func UnaryAgentRPCAPIInterceptor ¶
func UnaryAgentRPCAPIInterceptor(factory AgentRPCAPIFactory) grpc.UnaryServerInterceptor
UnaryAgentRPCAPIInterceptor returns a new unary server interceptor that augments connection context with a AgentRPCAPI.
Types ¶
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 AgentInfoResolver ¶
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 *slog.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 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 modshared.RPCAPIFromContext(ctx) instead. Log *slog.Logger // InstanceID can be used to distinguish kas replicas from each other. InstanceID int64 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 modshared.RPCAPIFromContext(requestContext). // Request handlers that block for a while must use context from // grpctool.MaxConnectionAgeContextFromStreamContext() or poll using rpcAPI.PollWithBackoff() // to respect RPC context abort, kas shutdown, max connection age reached conditions. AgentServer grpctool.GRPCServer // 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 modshared.RPCAPIFromContext(requestContext). // Request handlers that block for a while must use context from // grpctool.MaxConnectionAgeContextFromStreamContext() or poll using rpcAPI.PollWithBackoff() // to respect RPC context abort, kas shutdown, max connection age reached conditions. APIServer grpctool.GRPCServer // RegisterAgentAPI allows to register a gRPC API endpoint that kas proxies to agentk. RegisterAgentAPI func(*grpc.ServiceDesc) // AgentConnPool returns a gRPC connection that can be used to send requests to an agentk instance. // Make sure module factory returns modshared.ModuleStartAfterServers if module uses this connection. AgentConnPool func(agentID int64) grpc.ClientConnInterface // ListenerMetrics wraps a named net.Listener to collect metrics. ListenerMetrics func(l net.Listener, name string, ttl time.Duration) (net.Listener, error) Gitaly gitaly.PoolInterface TraceProvider trace.TracerProvider TracePropagator propagation.TextMapPropagator MeterProvider otelmetric.MeterProvider Meter otelmetric.Meter StreamClientProm grpc.StreamClientInterceptor UnaryClientProm grpc.UnaryClientInterceptor 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 the KAS version. Version string // GitRef is the Git reference of the KAS build. GitRef string // ProbeRegistry is for registering liveness probes and readiness probes. ProbeRegistry *observability.ProbeRegistry // List of available GitLab Releases Information GitLabReleasesList []string Validator prototool.Validator // Tracing enabled flags HTTPServerTracing bool HTTPClientTracing bool GRPCServerTracing bool GRPCClientTracing bool }
Config holds configuration for a Module.
func (*Config) MaybeTraceProvider ¶ added in v17.4.0
func (c *Config) MaybeTraceProvider(flag bool) trace.TracerProvider
Click to show internal directories.
Click to hide internal directories.