module

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

Agent type

func NewAgent

func NewAgent(httpClient *service.HTTPClient) *Agent

NewAgent creates a new instance

func (*Agent) Bootstrap

func (a *Agent) Bootstrap() error

Bootstrap registers an agent In order to register an agent, agent do a request to tower with the following specs

POST: config(agent.tower.url)/api/v1/action/register_agent

{
    "agentURL": "config(agent.url)"
    "agentID": "$$",
    "hostname": "$$"
    "agentApiKey": "$$"
}

Headers X-Encrypted-Request: true X-API-Key: config(agent.tower.apiKey)

func (*Agent) Heartbeat

func (a *Agent) Heartbeat() error

Heartbeat notify the tower that agent is a live

POST: config(agent.tower.url)/api/v1/action/agent_heartbeat

{
    "status": "up",
    "agentID": "$$",
    "hostname": "$$"
}

Headers X-Encrypted-Request: true X-API-Key: config(agent.tower.apiKey)

type BackupMessage

type BackupMessage struct {
	Action        string            `json:"action"`
	Cron          model.CronRecord  `json:"cron"`
	Job           model.JobRecord   `json:"job"`
	Settings      map[string]string `json:"settings"`
	CorrelationID string            `json:"CorrelationID"`
}

BackupMessage type

type BootstrapRequest

type BootstrapRequest struct {
	AgentURL    string `json:"agentURL"`
	Hostname    string `json:"hostname"`
	AgentID     string `json:"agentID"`
	AgentAPIKey string `json:"agentApiKey"`
}

BootstrapRequest type

type HeartbeatRequest

type HeartbeatRequest struct {
	Status   string `json:"status"`
	Hostname string `json:"hostname"`
	AgentID  string `json:"agentID"`
}

HeartbeatRequest type

type PostbackRequest

type PostbackRequest struct {
	JobID    string `json:"jobId"`
	CronID   string `json:"cronId"`
	Status   string `json:"status"`
	Hostname string `json:"hostname"`
	AgentID  string `json:"agentID"`
}

PostbackRequest type

type Stats

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

Stats type

func NewStats

func NewStats(db driver.Database) *Stats

NewStats creates a stats instance

func (*Stats) GetTotalHosts

func (s *Stats) GetTotalHosts() (int, error)

GetTotalHosts gets total hosts count

func (*Stats) GetTotalTowers

func (s *Stats) GetTotalTowers() (int, error)

GetTotalTowers gets total towers count

type Tower

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

Tower type

func NewTower

func NewTower(db driver.Database) *Tower

NewTower creates a new instance

func (*Tower) Alive

func (t *Tower) Alive(seconds int64) error

Alive report the tower as live to etcd

func (*Tower) Elect

func (t *Tower) Elect(seconds int64) error

Elect elect as leader

func (*Tower) HasLeader

func (t *Tower) HasLeader() (bool, error)

HasLeader checks if there is a leader

func (*Tower) IsLeader

func (t *Tower) IsLeader() (bool, error)

IsLeader checks if current tower is a leader

type Wire

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

Wire type

func NewWire

func NewWire(httpClient *service.HTTPClient, db driver.Database) *Wire

NewWire creates a new instance

func (*Wire) AgentPostback

func (w *Wire) AgentPostback(jobID, cronID, status string) error

AgentPostback trigger agent postback. It updates job status inside a tower

func (*Wire) SendJobToHostAgent

func (w *Wire) SendJobToHostAgent(message BackupMessage) error

SendJobToHostAgent updates a job status

func (*Wire) UpdateTowerJobStatus

func (w *Wire) UpdateTowerJobStatus(hostname, jobID, status string) error

UpdateTowerJobStatus updates a job status

Jump to

Keyboard shortcuts

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