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 ¶
- func ConnectionOptions(cfg *config.AgentConfig) (string, client.ConnectionOptions, error)
- func FindDefaultConfig(agentType string) string
- func LoadConfig(a Agent, configPath string) (*config.AgentConfig, string, error)
- func PBSCredentialsFetcher(cfg *config.AgentConfig, store *TokenStore) func(ctx context.Context, ticket string) (*backup.DirectOptions, error)
- func PrintEnrolled(a Agent, cfg *config.AgentConfig)
- func Run(a Agent, cfg *config.AgentConfig, configPath string, ...) error
- func ServerHTTPClient(cfg *config.AgentConfig) *http.Client
- func StartHeartbeat(ctx context.Context, cfg *config.AgentConfig, store *TokenStore, ...)
- func TicketGet(ctx context.Context, httpClient *http.Client, cfg *config.AgentConfig, ...) error
- type Agent
- type Conns
- type TokenStore
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 ¶
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 ¶
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
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
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