services

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearAgents

func ClearAgents()

ClearAgents shuts down all active agent processes gracefully.

The previous version sent SIGTERM and then immediately called conn.Close(), which sent SIGKILL — racing past the agent's own SIGTERM handler before it could reap its child processes (user binaries, Docker containers). conn.Close() is now graceful itself (SIGTERM → wait → SIGKILL fallback), so the explicit pre-signal here was both redundant and harmful.

Concurrency: snapshot under lock, swap to a fresh map, then Close outside the lock. Closing a gRPC conn can take several seconds (graceful SIGTERM grace) — holding the lock across it would block any concurrent LoadAgent.

func ForCreate added in v0.1.113

func ForCreate(opt *BuilderLoadOptions)

func ForSync added in v0.1.113

func ForSync(opt *BuilderLoadOptions)

func LoadAgent

func LoadAgent(ctx context.Context, agent *resources.Agent, cacheKey string) (*coreservices.ServiceAgent, error)

LoadAgent spawns the agent binary (or reuses a cached connection) and returns a ServiceAgent client. `cacheKey` scopes the cached connection — pass ServiceCacheKey(service) so each SERVICE gets an isolated agent process; an empty key falls back to the agent's unique (for non-service, agent-only operations). The underlying connection is cached internally and reused by LoadBuilder/ LoadRuntime (which must pass the SAME key) on the same process.

func LoadBuilder

func LoadBuilder(ctx context.Context, service *resources.Service) (*coreservices.BuilderAgent, error)

LoadBuilder creates a BuilderAgent from the cached agent connection.

func LoadCode added in v0.1.155

func LoadCode(ctx context.Context, service *resources.Service) (*coreservices.CodeAgent, error)

LoadCode creates a CodeAgent from the cached agent connection.

func LoadRuntime

func LoadRuntime(ctx context.Context, service *resources.Service) (*coreservices.RuntimeAgent, error)

LoadRuntime creates a RuntimeAgent from the cached agent connection.

func NetworkMappingForRestRouteGroup

func NetworkMappingForRestRouteGroup(ctx context.Context, group *resources.RestRouteGroup, mappings []*basev0.NetworkMapping) (*basev0.NetworkMapping, error)

NetworkMappingForRestRouteGroup finds the proper network mapping for a given route group

func ServiceCacheKey added in v0.2.12

func ServiceCacheKey(service *resources.Service) string

ServiceCacheKey is the per-SERVICE cache key for an agent connection. Two services using the same agent (e.g. two `go-grpc` services) MUST get their own agent process: the agent's Runtime holds per-service state (Endpoints, GrpcEndpoint, NetworkMappings) in a single struct, so a shared process lets the second service's Load overwrite the first's — and the first then resolves the second's endpoint ("no network instance for <other>/grpc"). Keying by service, not by agent, isolates that state. A service's own Builder+Runtime+Code still share ONE process (same key).

Types

type AddOutput added in v0.1.114

type AddOutput struct {
	ReadMe string
}

func Add

type AgentUpdate

type AgentUpdate struct {
	Name string
	From string
	To   string
}

type BuilderInstance

type BuilderInstance struct {
	*Instance

	Builder *services.BuilderAgent
}

func (*BuilderInstance) Audit added in v0.1.155

func (*BuilderInstance) Build added in v0.1.155

func (*BuilderInstance) Create

func (*BuilderInstance) Deploy added in v0.1.155

func (*BuilderInstance) Init added in v0.1.155

func (*BuilderInstance) Load

func (instance *BuilderInstance) Load(ctx context.Context, opts ...BuilderLoadOption) (*builderv0.LoadResponse, error)

func (*BuilderInstance) Sync

func (*BuilderInstance) Update added in v0.1.155

func (*BuilderInstance) Upgrade added in v0.1.155

type BuilderLoadOption added in v0.1.113

type BuilderLoadOption func(opt *BuilderLoadOptions)

type BuilderLoadOptions added in v0.1.113

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

type Instance

type Instance struct {
	Workspace *resources.Workspace
	Module    *resources.Module
	Service   *resources.Service

	Identity *resources.ServiceIdentity

	Agent *services.ServiceAgent
	Info  *agentv0.AgentInformation

	Builder *BuilderInstance
	Runtime *RuntimeInstance

	ProcessInfo
	Capabilities []*agentv0.Capability
}

func Load

func Load(ctx context.Context, workspace *resources.Workspace, module *resources.Module, service *resources.Service) (*Instance, error)

Load spawns a single agent process (or reuses a cached one) and creates all gRPC clients from the shared connection.

func (*Instance) CheckCapabilities

func (instance *Instance) CheckCapabilities(capability agentv0.Capability_Type) error

func (*Instance) LoadBuilder

func (instance *Instance) LoadBuilder(ctx context.Context) error

LoadBuilder creates a BuilderAgent from the shared connection.

func (*Instance) LoadRuntime

func (instance *Instance) LoadRuntime(ctx context.Context, withRuntimeCheck bool) error

LoadRuntime creates a RuntimeAgent from the shared connection.

func (*Instance) Unique added in v0.1.127

func (instance *Instance) Unique() string

func (*Instance) WithWorkspace

func (instance *Instance) WithWorkspace(workspace *resources.Workspace)

type ProcessInfo

type ProcessInfo struct {
	AgentPID int
}

type RuntimeInstance

type RuntimeInstance struct {
	*Instance

	Runtime *services.RuntimeAgent

	IsHotReloading bool
}

func (*RuntimeInstance) Destroy added in v0.1.155

func (*RuntimeInstance) Information added in v0.1.155

func (*RuntimeInstance) Init added in v0.1.155

func (*RuntimeInstance) Load

func (*RuntimeInstance) Start added in v0.1.155

func (*RuntimeInstance) Stop added in v0.1.155

func (*RuntimeInstance) Test added in v0.1.155

type UpdateInformation

type UpdateInformation struct {
	*AgentUpdate
}

func UpdateAgent

func UpdateAgent(ctx context.Context, service *resources.Service) (*UpdateInformation, error)

Jump to

Keyboard shortcuts

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