runtime

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package runtime is the shared daemon skeleton of the fallbck agents: configuration lookup and self-enrollment, the Temporal client and PBS tunnel connections through the server gateway, the activity worker, and the heartbeat / token-rotation loop. Agent binaries only add their activities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectionOptions

func ConnectionOptions(cfg *config.AgentConfig) (string, client.ConnectionOptions, error)

ConnectionOptions derives the Temporal gRPC endpoint and TLS settings from ServerURL. The FallBCK server multiplexes gRPC and HTTP on the same port; https → TLS, http → h2c.

func FindDefaultConfig

func FindDefaultConfig(agentType string) string

FindDefaultConfig returns the first existing agent.yaml among the conventional locations for the agent type: the default data dir (env / system dir as root / home), then the others.

func LoadConfig

func LoadConfig(a Agent, configPath string) (*config.AgentConfig, string, error)

LoadConfig loads the agent configuration (configPath or the default location) and self-enrolls when the agent has no identity but an enrollment key is configured (config file or FALLBCK_AGENT_ENROLLMENT_KEY). It returns the configuration and the path it should be persisted to.

func PBSCredentialsFetcher

func PBSCredentialsFetcher(cfg *config.AgentConfig, store *TokenStore) func(ctx context.Context, ticket string) (*backup.DirectOptions, error)

PBSCredentialsFetcher retrieves PBS connection details for direct-mode jobs

func PrintEnrolled

func PrintEnrolled(a Agent, cfg *config.AgentConfig)

PrintEnrolled prints the post-enrollment summary and how to start the service

func Run

func Run(a Agent, cfg *config.AgentConfig, configPath string, register func(w worker.Worker, conns *Conns, store *TokenStore) error) error

Run starts the daemon: connections, an activity-only worker on the agent's task queue with the activities registered by register, and the heartbeat loop; it blocks until SIGINT/SIGTERM.

func ServerHTTPClient

func ServerHTTPClient(cfg *config.AgentConfig) *http.Client

ServerHTTPClient builds the HTTP client for the FallBCK server (trusting a private CA if configured)

func StartHeartbeat

func StartHeartbeat(ctx context.Context, cfg *config.AgentConfig, store *TokenStore, version string)

StartHeartbeat reports the agent online every 30 s and rotates the token when it approaches expiry; it returns when ctx is cancelled

func TicketGet

func TicketGet(ctx context.Context, httpClient *http.Client, cfg *config.AgentConfig, store *TokenStore, path, ticket string, out any) error

TicketGet performs an agent-authenticated GET carrying a backup ticket and decodes the JSON response into out.

Types

type Agent

type Agent struct {
	// Name is the binary name (fallbck-agent, fallbck-db-agent); used for identities and messages
	Name string
	// Type is config.AgentTypeFilesystem or config.AgentTypeDatabase
	Type    string
	Version string
}

Agent identifies the binary using the runtime

type Conns

type Conns struct {
	HostPort string
	Temporal client.Client
	// Tunnel carries PBS backup sessions and other agent-authenticated gRPC services
	Tunnel *grpc.ClientConn
}

Conns are the agent's connections to the server gateway

func Connect

func Connect(cfg *config.AgentConfig, store *TokenStore, identity string) (*Conns, error)

Connect opens the Temporal client and the tunnel connection through the gateway, both authenticated with the agent token

func (*Conns) Close

func (c *Conns) Close()

Close releases both connections

type TokenStore

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

TokenStore holds the current agent token and persists rotations

func NewTokenStore

func NewTokenStore(cfg *config.AgentConfig, configPath string) *TokenStore

NewTokenStore wraps the loaded configuration; rotations are written to configPath

func (*TokenStore) ExpiresAt

func (t *TokenStore) ExpiresAt() time.Time

func (*TokenStore) Token

func (t *TokenStore) Token() string

func (*TokenStore) Update

func (t *TokenStore) Update(token string, expires time.Time) error

Update installs a rotated token and persists it (only the token fields are rewritten)

Jump to

Keyboard shortcuts

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