Documentation
¶
Overview ¶
Package logs manages asynchronous log sessions, source discovery, and streaming. Accepted sessions retain context values but outlive creation RPC cancellation. Resource sessions retain their native-generation lease until producers exit.
Index ¶
- Constants
- func RegisterLogPluginServer(registrar grpc.ServiceRegistrar, server logspb.LogPluginServer)
- func RegisterPlugin(p *sdk.Plugin, opts PluginOpts) error
- type ActionTargetBuilder
- type ChannelSink
- type CreateSessionOptions
- type Handler
- type LogHandlerFunc
- type LogLevel
- type LogLine
- type LogLineOrigin
- type LogSession
- type LogSessionOptions
- type LogSessionStatus
- type LogSource
- type LogStreamCommand
- type LogStreamEvent
- type LogStreamEventType
- type LogStreamRequest
- type Manager
- func (m *Manager) BindConnectionContextProvider(provider resourcev2.ConnectionContextProvider)
- func (m *Manager) Close()
- func (m *Manager) CloseSession(_ *types.PluginContext, sessionID string) error
- func (m *Manager) CreateResourceSession(pluginctx *types.PluginContext, opts CreateSessionOptions) (*LogSession, error)
- func (m *Manager) CreateSession(pluginctx *types.PluginContext, opts CreateSessionOptions) (*LogSession, error)
- func (m *Manager) GetSession(_ *types.PluginContext, sessionID string) (*LogSession, error)
- func (m *Manager) GetSupportedResources(_ *types.PluginContext) []Handler
- func (m *Manager) ListSessions(_ *types.PluginContext) ([]*LogSession, error)
- func (m *Manager) Stream(ctx context.Context, in chan StreamInput) (chan StreamOutput, error)
- func (m *Manager) UpdateSessionOptions(_ *types.PluginContext, sessionID string, opts LogSessionOptions) (*LogSession, error)
- func (m *Manager) Wait()
- type ManagerConfig
- type OutputSink
- type Plugin
- type PluginClient
- func (c *PluginClient) CloseSession(ctx *types.PluginContext, sessionID string) error
- func (c *PluginClient) CreateResourceSession(ctx *types.PluginContext, opts CreateSessionOptions) (*LogSession, error)
- func (c *PluginClient) CreateSession(ctx *types.PluginContext, opts CreateSessionOptions) (*LogSession, error)
- func (c *PluginClient) GetSession(ctx *types.PluginContext, sessionID string) (*LogSession, error)
- func (c *PluginClient) GetSupportedResources(ctx *types.PluginContext) []Handler
- func (c *PluginClient) ListSessions(ctx *types.PluginContext) ([]*LogSession, error)
- func (c *PluginClient) Stream(ctx context.Context, in chan StreamInput) (chan StreamOutput, error)
- func (c *PluginClient) UpdateSessionOptions(ctx *types.PluginContext, sessionID string, opts LogSessionOptions) (*LogSession, error)
- type PluginOpts
- type PluginServer
- func (s *PluginServer) CloseSession(ctx context.Context, in *logspb.LogSessionByIdRequest) (*logspb.CloseLogSessionResponse, error)
- func (s *PluginServer) CreateResourceSession(ctx context.Context, in *logspb.CreateLogSessionRequest) (*logspb.ResourceLogSessionResponse, error)
- func (s *PluginServer) CreateSession(ctx context.Context, in *logspb.CreateLogSessionRequest) (*logspb.CreateLogSessionResponse, error)
- func (s *PluginServer) GetSession(ctx context.Context, in *logspb.LogSessionByIdRequest) (*logspb.LogSessionByIdResponse, error)
- func (s *PluginServer) GetSupportedResources(ctx context.Context, _ *emptypb.Empty) (*logspb.GetSupportedLogResourcesResponse, error)
- func (s *PluginServer) ListSessions(ctx context.Context, _ *emptypb.Empty) (*logspb.ListLogSessionsResponse, error)
- func (s *PluginServer) Stream(stream logspb.LogPlugin_StreamServer) error
- func (s *PluginServer) UpdateSessionOptions(ctx context.Context, in *logspb.UpdateLogSessionOptionsRequest) (*logspb.LogSessionByIdResponse, error)
- type Provider
- type ResourceSessionProvider
- type SourceBuilderFunc
- type SourceEvent
- type SourceEventType
- type SourceResolver
- type SourceResolverOptions
- type SourceResolverResult
- type StreamInput
- type StreamOutput
Constants ¶
const ( // MaxConcurrentStreamsPerSession bounds simultaneous source readers in one session. MaxConcurrentStreamsPerSession = 20 // MaxScannerBuffer limits a single log line to one mebibyte. MaxScannerBuffer = 1024 * 1024 // ReconnectMaxAttempts bounds retries after the initial stream attempt. ReconnectMaxAttempts = 5 // ReconnectInitialDelay is the first retry's backoff. ReconnectInitialDelay = 1 * time.Second // ReconnectMaxDelay caps exponential retry backoff. ReconnectMaxDelay = 30 * time.Second )
const ResourceSessionWireVersion = resourcev2.WireVersion
ResourceSessionWireVersion identifies the canonical resource log-session wire contract.
Variables ¶
This section is empty.
Functions ¶
func RegisterLogPluginServer ¶ added in v0.9.0
func RegisterLogPluginServer(registrar grpc.ServiceRegistrar, server logspb.LogPluginServer)
RegisterLogPluginServer preserves generated lifecycle handlers while admitting resource session requests before generated decoding or provider side effects.
func RegisterPlugin ¶
func RegisterPlugin( p *sdk.Plugin, opts PluginOpts, ) error
RegisterPlugin registers the log capability with the plugin system.
Types ¶
type ActionTargetBuilder ¶
type ActionTargetBuilder struct {
Label string `json:"label"`
LabelSelector string `json:"label_selector"`
Paths []string `json:"paths"`
Selectors map[string]string `json:"selectors"`
}
ActionTargetBuilder builds a dynamic list of targets for an action.
func ActionTargetBuilderFromProto ¶
func ActionTargetBuilderFromProto(p *commonpb.ActionTargetBuilder) ActionTargetBuilder
ActionTargetBuilderFromProto converts a proto ActionTargetBuilder to the domain type.
func (ActionTargetBuilder) ToProto ¶
func (a ActionTargetBuilder) ToProto() *commonpb.ActionTargetBuilder
ToProto converts ActionTargetBuilder to its proto representation.
type ChannelSink ¶
type ChannelSink struct {
// contains filtered or unexported fields
}
ChannelSink writes StreamOutput to a channel with context-aware sends. Callers may inject it when a shared context should control delivery. If that context is canceled, sends stop blocking on a full channel.
func NewChannelSink ¶
func NewChannelSink(ctx context.Context, out chan StreamOutput) *ChannelSink
NewChannelSink creates a ChannelSink wrapping the given output channel. The context controls the lifetime — sends are dropped after cancellation.
func (*ChannelSink) OnEvent ¶
func (s *ChannelSink) OnEvent(sessionID string, event LogStreamEvent)
OnEvent sends a session event or returns when the sink context is canceled.
func (*ChannelSink) OnLine ¶
func (s *ChannelSink) OnLine(line LogLine)
OnLine sends a line or returns when the sink context is canceled.
type CreateSessionOptions ¶
type CreateSessionOptions struct {
// SessionID optionally binds resource-session acceptance to a host-generated UUID.
SessionID string `json:"session_id,omitempty"`
ResourceKey string `json:"resource_key"`
ResourceID string `json:"resource_id"`
ResourceData *resourcev2.Value `json:"resource_data"`
Reference *resourcev2.ResourceReference `json:"reference,omitempty"`
Route *resourcev2.AccessRoute `json:"route,omitempty"`
Options LogSessionOptions `json:"options"`
}
CreateSessionOptions contains everything needed to create a log session.
func CreateSessionOptionsFromProto ¶ added in v0.9.0
func CreateSessionOptionsFromProto(p *logspb.CreateLogSessionRequest) (CreateSessionOptions, error)
CreateSessionOptionsFromProto rejects unknown fields and unsupported versions before decoding canonical values. Optional reference, route, and body presence survives conversion.
func (CreateSessionOptions) HasResourceIntent ¶ added in v0.9.0
func (o CreateSessionOptions) HasResourceIntent() bool
HasResourceIntent reports whether options must use the resource-aware creation path.
func (CreateSessionOptions) ToProto ¶ added in v0.9.0
func (o CreateSessionOptions) ToProto() (*logspb.CreateLogSessionRequest, error)
ToProto validates options and bounds the encoded frame before allocating the resource body.
func (*CreateSessionOptions) UnmarshalJSON ¶ added in v0.9.0
func (o *CreateSessionOptions) UnmarshalJSON(data []byte) error
UnmarshalJSON preserves raw validation evidence and admits only exact field names.
func (CreateSessionOptions) Validate ¶ added in v0.9.0
func (o CreateSessionOptions) Validate() error
Validate checks canonical metadata and values without requiring a live connection.
type Handler ¶
type Handler struct {
Plugin string `json:"plugin"`
Resource string `json:"resource"`
TargetBuilder ActionTargetBuilder `json:"target_builder"`
Handler LogHandlerFunc `json:"-"`
SourceBuilder SourceBuilderFunc `json:"-"`
}
Handler describes a log handler for a specific resource type.
func HandlerFromProto ¶
func HandlerFromProto(p *logspb.LogHandler) Handler
HandlerFromProto decodes handler metadata; callbacks must be registered locally.
func (Handler) ToProto ¶
func (h Handler) ToProto() *logspb.LogHandler
ToProto encodes handler metadata without its executable callbacks.
type LogHandlerFunc ¶
type LogHandlerFunc func(ctx *types.PluginContext, req LogStreamRequest) (io.ReadCloser, error)
LogHandlerFunc opens a log stream for a single source, returning an io.ReadCloser.
type LogLevel ¶
type LogLevel int
LogLevel represents the severity level of a log line.
const ( // LogLevelUnspecified indicates that no severity was assigned. LogLevelUnspecified LogLevel = iota // LogLevelTrace identifies fine-grained execution tracing. LogLevelTrace // LogLevelDebug identifies diagnostic output. LogLevelDebug // LogLevelInfo identifies routine informational output. LogLevelInfo // LogLevelWarn identifies a potential problem. LogLevelWarn // LogLevelError identifies a failed operation. LogLevelError // LogLevelFatal identifies a failure that prevents continued operation. LogLevelFatal )
func LogLevelFromProto ¶
LogLevelFromProto decodes severity, defaulting unknown values to unspecified.
type LogLine ¶
type LogLine struct {
SessionID string `json:"session_id"`
SourceID string `json:"source_id"`
Labels map[string]string `json:"labels"`
Timestamp time.Time `json:"timestamp"`
Content string `json:"content"`
Origin LogLineOrigin `json:"origin"`
Level LogLevel `json:"level"`
}
LogLine represents a single log line from any source.
func LogLineFromProto ¶
LogLineFromProto decodes line content, sharing Labels; an absent timestamp stays zero.
type LogLineOrigin ¶
type LogLineOrigin int
LogLineOrigin indicates the origin of a log line.
const ( // LogLineOriginCurrent identifies output from the current source instance. LogLineOriginCurrent LogLineOrigin = iota // LogLineOriginPrevious identifies output retained from a previous source instance. LogLineOriginPrevious // LogLineOriginSystem identifies messages generated by the log engine. LogLineOriginSystem )
func LogLineOriginFromProto ¶
func LogLineOriginFromProto(p logspb.LogLineOrigin) LogLineOrigin
LogLineOriginFromProto decodes the origin, defaulting unknown values to current.
func (LogLineOrigin) ToProto ¶
func (o LogLineOrigin) ToProto() logspb.LogLineOrigin
ToProto encodes the origin, defaulting unknown values to current.
type LogSession ¶
type LogSession struct {
ID string `json:"id"`
PluginID string `json:"plugin_id"`
ConnectionID string `json:"connection_id"`
ResourceKey string `json:"resource_key"`
ResourceID string `json:"resource_id"`
Options LogSessionOptions `json:"options"`
Status LogSessionStatus `json:"status"`
ActiveSources []LogSource `json:"active_sources"`
CreatedAt time.Time `json:"created_at"`
}
LogSession represents an active log viewing session.
func LogSessionFromProto ¶
func LogSessionFromProto(p *logspb.LogSession) *LogSession
LogSessionFromProto decodes a session snapshot without opening native sources.
func (*LogSession) ToProto ¶
func (s *LogSession) ToProto() *logspb.LogSession
ToProto encodes the session snapshot and its active sources.
type LogSessionOptions ¶
type LogSessionOptions struct {
Reference *resourcev2.ResourceReference `json:"-"`
Route *resourcev2.AccessRoute `json:"-"`
Target string `json:"target"`
Follow bool `json:"follow"`
IncludePrevious bool `json:"include_previous"`
IncludeTimestamps bool `json:"include_timestamps"`
TailLines int64 `json:"tail_lines"`
SinceSeconds int64 `json:"since_seconds"`
SinceTime *time.Time `json:"since_time,omitempty"`
LimitBytes int64 `json:"limit_bytes"`
IncludeSourceEvents bool `json:"include_source_events"`
Params map[string]string `json:"params"`
}
LogSessionOptions contains options for creating or updating a log session.
func LogSessionOptionsFromProto ¶
func LogSessionOptionsFromProto(p *logspb.LogSessionOptions) LogSessionOptions
LogSessionOptionsFromProto decodes stream options and shares the wire Params map. Nil input produces zero options without resource admission metadata.
func (*LogSessionOptions) ToProto ¶
func (o *LogSessionOptions) ToProto() *logspb.LogSessionOptions
ToProto encodes stream options, sharing Params and omitting Reference and Route. A nil receiver produces nil; resource admission metadata travels separately.
type LogSessionStatus ¶
type LogSessionStatus int
LogSessionStatus represents the status of a log session.
const ( // LogSessionStatusActive indicates that the session is delivering logs. LogSessionStatusActive LogSessionStatus = iota // LogSessionStatusPaused indicates that log delivery is suspended. LogSessionStatusPaused // LogSessionStatusClosed indicates that the session has ended. LogSessionStatusClosed // LogSessionStatusError indicates that the session encountered a failure. LogSessionStatusError // LogSessionStatusConnecting indicates that native source acquisition is pending. LogSessionStatusConnecting // LogSessionStatusInitializing indicates that session setup is in progress. LogSessionStatusInitializing )
func LogSessionStatusFromProto ¶
func LogSessionStatusFromProto(p logspb.LogSessionStatus) LogSessionStatus
LogSessionStatusFromProto decodes a wire status, defaulting unknown values to active.
func (LogSessionStatus) ToProto ¶
func (s LogSessionStatus) ToProto() logspb.LogSessionStatus
ToProto converts the status to its wire value, defaulting unknown values to active.
type LogSource ¶
LogSource is a generic log-producing entity.
func LogSourceFromProto ¶
LogSourceFromProto decodes source identity and shares the wire Labels map.
type LogStreamCommand ¶
type LogStreamCommand int
LogStreamCommand represents a command from the client to control the stream.
const ( // StreamCommandPause requests suspension of log delivery. StreamCommandPause LogStreamCommand = iota // StreamCommandResume requests continuation of log delivery. StreamCommandResume // StreamCommandClose requests termination of the session. StreamCommandClose )
func LogStreamCommandFromProto ¶
func LogStreamCommandFromProto(p logspb.LogStreamCommand) LogStreamCommand
LogStreamCommandFromProto decodes the command, defaulting unknown values to pause.
func (LogStreamCommand) ToProto ¶
func (c LogStreamCommand) ToProto() logspb.LogStreamCommand
ToProto encodes the command, defaulting unknown values to pause.
type LogStreamEvent ¶
type LogStreamEvent struct {
Type LogStreamEventType `json:"type"`
SourceID string `json:"source_id"`
Message string `json:"message"`
Timestamp time.Time `json:"timestamp"`
}
LogStreamEvent represents a lifecycle event during streaming.
func LogStreamEventFromProto ¶
func LogStreamEventFromProto(p *logspb.LogStreamEvent) LogStreamEvent
LogStreamEventFromProto decodes event details; an absent timestamp stays zero.
func (*LogStreamEvent) ToProto ¶
func (e *LogStreamEvent) ToProto() *logspb.LogStreamEvent
ToProto encodes the event details and timestamp.
type LogStreamEventType ¶
type LogStreamEventType int
LogStreamEventType represents the type of log stream event.
const ( // StreamEventSourceAdded announces a source joining the session. StreamEventSourceAdded LogStreamEventType = iota // StreamEventSourceRemoved announces a source leaving the session. StreamEventSourceRemoved // StreamEventStreamError reports a source stream failure. StreamEventStreamError // StreamEventReconnecting announces a pending source reconnection. StreamEventReconnecting // StreamEventReconnected announces a successful source reconnection. StreamEventReconnected // StreamEventStreamEnded announces completion of a source stream. StreamEventStreamEnded // StreamEventSessionReady announces completion of session source setup. StreamEventSessionReady )
func LogStreamEventTypeFromProto ¶
func LogStreamEventTypeFromProto(p logspb.LogStreamEventType) LogStreamEventType
LogStreamEventTypeFromProto decodes the event kind, defaulting unknown values to source-added.
func (LogStreamEventType) String ¶
func (t LogStreamEventType) String() string
String returns the event name or a numeric description for unknown values.
func (LogStreamEventType) ToProto ¶
func (t LogStreamEventType) ToProto() logspb.LogStreamEventType
ToProto encodes the event kind, defaulting unknown values to source-added.
type LogStreamRequest ¶
type LogStreamRequest struct {
SourceID string
Labels map[string]string
ResourceData *resourcev2.Value `json:"resource_data"`
Reference *resourcev2.ResourceReference `json:"reference,omitempty"`
Route *resourcev2.AccessRoute `json:"route,omitempty"`
Target string
Follow bool
IncludePrevious bool
IncludeTimestamps bool
TailLines int64
SinceSeconds int64
SinceTime *time.Time
LimitBytes int64
Params map[string]string
}
LogStreamRequest is the generic request to open a log stream for one source.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages the lifecycle of log sessions within a plugin process.
func NewManager ¶
func NewManager(cfg ManagerConfig) *Manager
NewManager creates a new Manager with the given config.
func (*Manager) BindConnectionContextProvider ¶ added in v0.9.0
func (m *Manager) BindConnectionContextProvider(provider resourcev2.ConnectionContextProvider)
BindConnectionContextProvider binds resource sessions to the active source generation.
func (*Manager) Close ¶
func (m *Manager) Close()
Close cancels all active sessions and waits for their goroutines to finish.
func (*Manager) CloseSession ¶
func (m *Manager) CloseSession(_ *types.PluginContext, sessionID string) error
CloseSession removes and cancels a session, waiting up to the shutdown timeout. An unknown ID returns an error; a timeout is logged rather than returned.
func (*Manager) CreateResourceSession ¶ added in v0.9.0
func (m *Manager) CreateResourceSession( pluginctx *types.PluginContext, opts CreateSessionOptions, ) (*LogSession, error)
CreateResourceSession admits a configured connection and registers a connecting session; native handler/resolver acquisition proceeds asynchronously. The returned session is not a readiness receipt. Its lifetime is independent of the initiating RPC and ends through CloseSession, generation retirement, or shutdown.
The configured-generation lease remains held until every native producer exits. Retirement cancels the session, but cannot destroy a client still in use.
func (*Manager) CreateSession ¶
func (m *Manager) CreateSession( pluginctx *types.PluginContext, opts CreateSessionOptions, ) (*LogSession, error)
CreateSession registers a legacy session and starts acquisition asynchronously. A successful return does not imply readiness; close the session explicitly.
func (*Manager) GetSession ¶
func (m *Manager) GetSession(_ *types.PluginContext, sessionID string) (*LogSession, error)
GetSession returns an independent session snapshot, or an error for an unknown ID.
func (*Manager) GetSupportedResources ¶
func (m *Manager) GetSupportedResources(_ *types.PluginContext) []Handler
GetSupportedResources returns the registered handler descriptions.
func (*Manager) ListSessions ¶
func (m *Manager) ListSessions(_ *types.PluginContext) ([]*LogSession, error)
ListSessions returns session snapshots sorted by ID.
func (*Manager) Stream ¶
func (m *Manager) Stream(ctx context.Context, in chan StreamInput) (chan StreamOutput, error)
Stream starts command handling and returns the shared output channel. With a configured sink, output is nil. Cancellation or closed input cancels sessions.
func (*Manager) UpdateSessionOptions ¶
func (m *Manager) UpdateSessionOptions( _ *types.PluginContext, sessionID string, opts LogSessionOptions, ) (*LogSession, error)
UpdateSessionOptions replaces mutable options while preserving the admitted target. The enabled_sources parameter cancels disabled sources and restarts enabled sources.
type ManagerConfig ¶
type ManagerConfig struct {
Logger logging.Logger
Settings settings.Provider
Handlers map[string]Handler
Resolvers map[string]SourceResolver
Sink OutputSink // optional: nil → bounded shared output channel
Clock timeutil.Clock // optional: nil → timeutil.RealClock
}
ManagerConfig configures the Manager.
type OutputSink ¶
type OutputSink interface {
OnLine(line LogLine)
OnEvent(sessionID string, event LogStreamEvent)
}
OutputSink receives log lines and stream events from the Manager. Tests inject RecordingOutput; callers may inject a custom sink instead of the Manager's default session-cancellable output channel.
type Plugin ¶
Plugin implements the hashicorp go-plugin interfaces for log capability.
func (*Plugin) BindConnectionContextProvider ¶ added in v0.9.0
func (p *Plugin) BindConnectionContextProvider(provider resourcev2.ConnectionContextProvider)
BindConnectionContextProvider forwards the source binding to providers that consume it.
func (*Plugin) GRPCClient ¶
func (p *Plugin) GRPCClient( _ context.Context, _ *plugin.GRPCBroker, c *grpc.ClientConn, ) (any, error)
GRPCClient creates a remote log provider using the supplied connection.
func (*Plugin) GRPCServer ¶
GRPCServer registers log lifecycle and raw resource-admission handlers.
type PluginClient ¶
type PluginClient struct {
// contains filtered or unexported fields
}
PluginClient adapts remote log RPCs to Provider without downgrading resource requests.
func (*PluginClient) CloseSession ¶
func (c *PluginClient) CloseSession(ctx *types.PluginContext, sessionID string) error
CloseSession requests remote cleanup for the named session.
func (*PluginClient) CreateResourceSession ¶ added in v0.9.0
func (c *PluginClient) CreateResourceSession(ctx *types.PluginContext, opts CreateSessionOptions) (*LogSession, error)
CreateResourceSession checks the trusted route and validates the admitted remote result.
func (*PluginClient) CreateSession ¶
func (c *PluginClient) CreateSession( ctx *types.PluginContext, opts CreateSessionOptions, ) (*LogSession, error)
CreateSession selects the resource RPC whenever options carry resource intent.
func (*PluginClient) GetSession ¶
func (c *PluginClient) GetSession( ctx *types.PluginContext, sessionID string, ) (*LogSession, error)
GetSession retrieves a remote session by ID.
func (*PluginClient) GetSupportedResources ¶
func (c *PluginClient) GetSupportedResources(ctx *types.PluginContext) []Handler
GetSupportedResources lists remote handlers, returning nil when discovery fails.
func (*PluginClient) ListSessions ¶
func (c *PluginClient) ListSessions(ctx *types.PluginContext) ([]*LogSession, error)
ListSessions returns the remote provider's current sessions.
func (*PluginClient) Stream ¶
func (c *PluginClient) Stream( ctx context.Context, in chan StreamInput, ) (chan StreamOutput, error)
Stream forwards input and output until cancellation or transport termination. Closing input closes the send side; the receiver owns and closes the output channel.
func (*PluginClient) UpdateSessionOptions ¶
func (c *PluginClient) UpdateSessionOptions( ctx *types.PluginContext, sessionID string, opts LogSessionOptions, ) (*LogSession, error)
UpdateSessionOptions changes streaming options for an existing remote session.
type PluginOpts ¶
type PluginOpts struct {
// Handlers maps resource keys to their log handlers.
// For example: "core::v1::Pod" -> Handler
Handlers map[string]Handler `json:"handlers"`
// SourceResolvers maps resource keys to source resolvers that resolve
// group resources into individual log sources.
// For example: "apps::v1::Deployment" -> SourceResolver
SourceResolvers map[string]SourceResolver `json:"-"`
}
PluginOpts contains the options for the log plugin.
type PluginServer ¶
type PluginServer struct {
Impl Provider
// contains filtered or unexported fields
}
PluginServer adapts a log provider to gRPC and preserves resource error classification.
func (*PluginServer) CloseSession ¶
func (s *PluginServer) CloseSession( ctx context.Context, in *logspb.LogSessionByIdRequest, ) (*logspb.CloseLogSessionResponse, error)
CloseSession requests provider cleanup for the named session.
func (*PluginServer) CreateResourceSession ¶ added in v0.9.0
func (s *PluginServer) CreateResourceSession( ctx context.Context, in *logspb.CreateLogSessionRequest, ) (*logspb.ResourceLogSessionResponse, error)
CreateResourceSession validates wire version, trusted route, and provider result before returning a session.
func (*PluginServer) CreateSession ¶
func (s *PluginServer) CreateSession( ctx context.Context, in *logspb.CreateLogSessionRequest, ) (*logspb.CreateLogSessionResponse, error)
CreateSession serves legacy requests and rejects resource intent without fallback.
func (*PluginServer) GetSession ¶
func (s *PluginServer) GetSession( ctx context.Context, in *logspb.LogSessionByIdRequest, ) (*logspb.LogSessionByIdResponse, error)
GetSession retrieves one session by ID through the provider.
func (*PluginServer) GetSupportedResources ¶
func (s *PluginServer) GetSupportedResources( ctx context.Context, _ *emptypb.Empty, ) (*logspb.GetSupportedLogResourcesResponse, error)
GetSupportedResources returns the provider's registered log handlers.
func (*PluginServer) ListSessions ¶
func (s *PluginServer) ListSessions( ctx context.Context, _ *emptypb.Empty, ) (*logspb.ListLogSessionsResponse, error)
ListSessions returns the provider's current sessions.
func (*PluginServer) Stream ¶
func (s *PluginServer) Stream(stream logspb.LogPlugin_StreamServer) error
Stream forwards bidirectional log traffic until the RPC ends or receiving fails.
func (*PluginServer) UpdateSessionOptions ¶
func (s *PluginServer) UpdateSessionOptions( ctx context.Context, in *logspb.UpdateLogSessionOptionsRequest, ) (*logspb.LogSessionByIdResponse, error)
UpdateSessionOptions applies streaming options to an existing session.
type Provider ¶
type Provider interface {
GetSupportedResources(ctx *types.PluginContext) []Handler
CreateSession(ctx *types.PluginContext, opts CreateSessionOptions) (*LogSession, error)
GetSession(ctx *types.PluginContext, sessionID string) (*LogSession, error)
ListSessions(ctx *types.PluginContext) ([]*LogSession, error)
CloseSession(ctx *types.PluginContext, sessionID string) error
UpdateSessionOptions(ctx *types.PluginContext, sessionID string, opts LogSessionOptions) (*LogSession, error)
Stream(ctx context.Context, in chan StreamInput) (chan StreamOutput, error)
}
Provider is the interface satisfied by the plugin server and client to provide log viewing functionality.
type ResourceSessionProvider ¶ added in v0.9.0
type ResourceSessionProvider interface {
CreateResourceSession(*types.PluginContext, CreateSessionOptions) (*LogSession, error)
}
ResourceSessionProvider extends the existing log lifecycle without converting resource bodies through JSON maps or Struct. Resource data remains a canonical Value; references and routes are optional actual caller bindings. Resource creation never falls back to the legacy CreateSession RPC. Admission inherits creation cancellation; accepted native callbacks retain its values under the native-generation lifetime. A missing serialized plugin context does not create a connection or authority; explicit routes still require a matching connection supplied through the caller's plugin metadata. SessionID correlates acceptance and cleanup only; it confers no authority and does not make creation idempotent. Owners must close the chosen ID after a failed or lost response. Manager retains the generation until producers drain.
type SourceBuilderFunc ¶
type SourceBuilderFunc func( resourceID string, resourceData *resourcev2.Value, opts LogSessionOptions, ) []LogSource
SourceBuilderFunc builds LogSources from resource data for direct handler streaming. Plugins implement this to translate their resource data into properly-labeled sources that the LogHandlerFunc can consume. For example, a K8s plugin extracts pod name, namespace, and container names from the pod spec.
type SourceEvent ¶
type SourceEvent struct {
Type SourceEventType
Source LogSource
}
SourceEvent represents a source lifecycle change.
type SourceEventType ¶
type SourceEventType int
SourceEventType represents the type of source lifecycle event.
const ( // SourceAdded announces a newly available log source. SourceAdded SourceEventType = iota // SourceRemoved announces that a log source is no longer available. SourceRemoved )
type SourceResolver ¶
type SourceResolver func( ctx *types.PluginContext, resourceData *resourcev2.Value, opts SourceResolverOptions, ) (*SourceResolverResult, error)
SourceResolver resolves a "group" resource into individual log sources.
type SourceResolverOptions ¶
type SourceResolverOptions struct {
Reference *resourcev2.ResourceReference
Route *resourcev2.AccessRoute
Watch bool // if true, also return a channel for source changes
Target string // optional filter (e.g., specific container name)
Params map[string]string // plugin-specific resolver params
}
SourceResolverOptions configures how sources are resolved.
type SourceResolverResult ¶
type SourceResolverResult struct {
Sources []LogSource // current sources
Events <-chan SourceEvent // source lifecycle stream (nil if Watch=false)
}
SourceResolverResult contains the resolved sources and optional event channel.
type StreamInput ¶
type StreamInput struct {
SessionID string `json:"session_id"`
Command LogStreamCommand `json:"command"`
}
StreamInput is a control message from the client to the stream.
func StreamInputFromProto ¶
func StreamInputFromProto(p *logspb.LogStreamInput) StreamInput
StreamInputFromProto decodes a session-scoped stream control message.
func (*StreamInput) ToProto ¶
func (i *StreamInput) ToProto() *logspb.LogStreamInput
ToProto encodes a session-scoped stream control message.
type StreamOutput ¶
type StreamOutput struct {
SessionID string
Line *LogLine
Event *LogStreamEvent
}
StreamOutput is a log line or event from the stream.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package logtest provides programmable log sources, output recorders, and a harness that exercises the real log manager with context-aware test streams.
|
Package logtest provides programmable log sources, output recorders, and a harness that exercises the real log manager with context-aware test streams. |