agent

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Overview

Package agent provides agent helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildServer

type BuildServer struct {
	apiv1.UnimplementedBuildServiceServer
	Service buildsvc.Service
	Mirror  *MirrorServer
	Logger  logr.Logger
}

BuildServer exposes buildsvc over gRPC.

func (*BuildServer) RunBuild

RunBuild executes a remote build and streams progress.

type Config

type Config struct {
	ListenAddr                string
	KubeconfigPath            string
	KubeContext               string
	AuthToken                 string
	HTTPListenAddr            string
	TLSCertFile               string
	TLSKeyFile                string
	TLSClientCAFile           string
	MirrorStore               string
	MirrorMaxSessions         int
	MirrorMaxFramesPerSession uint64
	MirrorMaxBytes            int64
	MirrorPruneInterval       time.Duration
}

Config defines the runtime settings for the gRPC agent.

type DeployServer

type DeployServer struct {
	apiv1.UnimplementedDeployServiceServer
	Logger logr.Logger
	Mirror *MirrorServer
}

DeployServer exposes deploy apply/destroy workflows over gRPC.

func (*DeployServer) Apply

Apply runs the Helm upgrade/install workflow remotely.

func (*DeployServer) Destroy

Destroy removes a Helm release remotely.

type LogServer

type LogServer struct {
	apiv1.UnimplementedLogServiceServer
	Config Config
	Logger logr.Logger
	Mirror *MirrorServer
}

LogServer relays torque log streams over gRPC.

func (*LogServer) StreamLogs

func (s *LogServer) StreamLogs(req *apiv1.LogRequest, stream apiv1.LogService_StreamLogsServer) (retErr error)

StreamLogs executes a tailer instance and streams log lines to clients.

type MirrorServer

type MirrorServer struct {
	apiv1.UnimplementedMirrorServiceServer
	// contains filtered or unexported fields
}

MirrorServer implements the gRPC mirror bus.

The server can optionally persist frames via a MirrorStore so sessions are replayable across restarts.

func NewMirrorServer

func NewMirrorServer(opts ...MirrorServerOption) *MirrorServer

NewMirrorServer constructs a mirror bus server.

func (*MirrorServer) Close

func (s *MirrorServer) Close() error

func (*MirrorServer) Export

func (*MirrorServer) GetSession

func (*MirrorServer) Publish

Publish accepts frames from producers.

func (*MirrorServer) SetSessionMeta

func (*MirrorServer) SetSessionStatus

func (*MirrorServer) Subscribe

Subscribe streams frames for a session to the caller.

func (*MirrorServer) UpsertSessionMeta

func (s *MirrorServer) UpsertSessionMeta(ctx context.Context, sessionID string, meta MirrorSessionMeta, tags map[string]string) MirrorSession

UpsertSessionMeta updates in-memory and durable metadata for a session. It's safe to call this even if the session has no frames yet.

func (*MirrorServer) UpsertSessionStatus

func (s *MirrorServer) UpsertSessionStatus(ctx context.Context, sessionID string, st MirrorSessionStatus) MirrorSession

UpsertSessionStatus updates in-memory and durable lifecycle state for a session. It's safe to call this even if the session has no frames yet.

type MirrorServerOption

type MirrorServerOption func(*MirrorServer)

func WithMirrorBuffer

func WithMirrorBuffer(n int) MirrorServerOption

func WithMirrorStore

func WithMirrorStore(store MirrorStore) MirrorServerOption

type MirrorSession

type MirrorSession struct {
	SessionID        string
	CreatedUnixNano  int64
	LastSeenUnixNano int64
	LastSequence     uint64
	Meta             MirrorSessionMeta
	Tags             map[string]string
	Status           MirrorSessionStatus
}

MirrorSession holds lightweight metadata about a mirror session stored by a flight recorder.

type MirrorSessionMeta

type MirrorSessionMeta struct {
	Command     string
	Args        []string
	Requester   string
	Cluster     string
	KubeContext string
	Namespace   string
	Release     string
	Chart       string
}

MirrorSessionMeta holds optional fields that make sessions searchable and self-describing for UIs and AI agents.

type MirrorSessionState

type MirrorSessionState int32
const (
	MirrorSessionStateUnspecified MirrorSessionState = 0
	MirrorSessionStateRunning     MirrorSessionState = 1
	MirrorSessionStateDone        MirrorSessionState = 2
	MirrorSessionStateError       MirrorSessionState = 3
)

type MirrorSessionStatus

type MirrorSessionStatus struct {
	State             MirrorSessionState
	ExitCode          int32
	ErrorMessage      string
	CompletedUnixNano int64
}

MirrorSessionStatus is a lightweight lifecycle marker for UIs/agents.

type MirrorStore

type MirrorStore interface {
	Append(frame *apiv1.MirrorFrame) error
	UpsertSessionMeta(ctx context.Context, sessionID string, meta MirrorSessionMeta, tags map[string]string) error
	UpsertSessionStatus(ctx context.Context, sessionID string, st MirrorSessionStatus) error
	DeleteSession(ctx context.Context, sessionID string) (bool, error)
	GetSession(ctx context.Context, sessionID string) (MirrorSession, bool, error)
	ListSessions(ctx context.Context, limit int) ([]MirrorSession, error)
	Replay(ctx context.Context, sessionID string, fromSequence uint64, send func(*apiv1.MirrorFrame) error) (lastSequence uint64, _ error)
	Close() error
}

MirrorStore is an optional durable backend for MirrorService.

Append must be fast; implementations should batch/flush asynchronously.

func OpenMirrorStore

func OpenMirrorStore(path string, opts MirrorStoreOptions) (MirrorStore, error)

OpenMirrorStore opens a SQLite-backed flight recorder database. If path is empty, it returns (nil, nil) and the mirror bus stays in-memory only.

type MirrorStoreOptions

type MirrorStoreOptions struct {
	MaxSessions         int
	MaxFramesPerSession uint64
	MaxBytes            int64
	PruneInterval       time.Duration
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server wraps the gRPC agent server state.

func New

func New(cfg Config, svc buildsvc.Service) (*Server, error)

New constructs a Server with default dependencies.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the gRPC server.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, ln net.Listener) error

Serve starts the gRPC server on an existing listener.

Jump to

Keyboard shortcuts

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