domain

package
v0.0.0-...-8865ca3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2015 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	POLICY_ALL = "all"
	POLICY_ANY = "any"
)
View Source
const (
	CONN_LOCAL = "local"
	CONN_SSH   = "ssh"
)
View Source
const (
	STATUS_UP = iota
	STATUS_DOWN
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	Command() []string
}

type ConnectionOptions

type ConnectionOptions struct {
	SshHost    string `json:"ssh_host"`
	SshUser    string `json:"ssh_user"`
	SshKeyFile string `json:"ssh_private_key_file"`
}

func (ConnectionOptions) IsValid

func (o ConnectionOptions) IsValid(forType ConnectionType) error

func (ConnectionOptions) SetDefaults

func (o ConnectionOptions) SetDefaults(forType string)

type ConnectionType

type ConnectionType string

type DurationJson

type DurationJson struct {
	Milliseconds float64 `json:"milliseconds"`
	String       string  `json:"string"`
}

type ExecCommand

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

func (ExecCommand) Command

func (e ExecCommand) Command() []string

type ExecutionPolicy

type ExecutionPolicy struct {
	Hosts    string
	HostList []string
	Roles    []string
}

func NewExecutionPolicyFromJson

func NewExecutionPolicyFromJson(json ExecutionPolicyJson) (ExecutionPolicy, error)

func (ExecutionPolicy) IsValid

func (p ExecutionPolicy) IsValid() error

type ExecutionPolicyJson

type ExecutionPolicyJson struct {
	Hosts    string   `json:"select"`
	HostList []string `json:"hosts"`
	Roles    []string `json:"roles"`
}

type ExecutionStrategy

type ExecutionStrategy interface {
	HealthCheck() error
	ExecuteCommand(job *Job, report *RunReportItem) error
}

type Job

type Job struct {
	// Domain properties
	Name          string
	Description   string
	Owners        []JobOwner
	Policy        ExecutionPolicy
	Schedule      cron.Schedule
	ScheduleSpec  string
	Command       Command
	LastExecution time.Time
	Environment   map[string]string

	// Auxiliary properties
	Logger *logging.Logger
	Lock   sync.RWMutex
}

func NewJobFromJson

func NewJobFromJson(name string, json JobJson) (Job, error)

func (Job) IsValid

func (j Job) IsValid(config JobValidationConfig) error

type JobJson

type JobJson struct {
	Description  string              `json:"description"`
	Owners       []JobOwnerJson      `json:"owners"`
	Policy       ExecutionPolicyJson `json:"policy"`
	Schedule     string              `json:"schedule"`
	ShellCommand string              `json:"shell_command"`
	Command      []string            `json:"command"`
	Environment  map[string]string   `json:"environment"`
}

type JobOwner

type JobOwner struct {
	Name         string
	EmailAddress string
}

func NewJobOwnerFromJson

func NewJobOwnerFromJson(json JobOwnerJson) (JobOwner, error)

func (JobOwner) IsValid

func (o JobOwner) IsValid() error

type JobOwnerJson

type JobOwnerJson struct {
	Name         string `json:"name"`
	EmailAddress string `json:"email_address"`
}

type JobValidationConfig

type JobValidationConfig interface {
	AllowNoOwner() bool
}

type Node

type Node struct {
	Name              string
	Roles             []string
	ConnectionType    ConnectionType
	ConnectionOptions ConnectionOptions
	Status            NodeStatus
	RunningJobs       int32

	ExecutionStrategy ExecutionStrategy
	Lock              sync.RWMutex
}

func NewNodeFromJson

func NewNodeFromJson(name string, json NodeJson) (Node, error)

func (Node) IsValid

func (n Node) IsValid() error

type NodeJson

type NodeJson struct {
	Name              string            `json:"name"`
	Roles             []string          `json:"roles"`
	ConnectionType    string            `json:"connection_type"`
	ConnectionOptions ConnectionOptions `json:"connection_options"`
}

type NodeStatus

type NodeStatus int

type RunReport

type RunReport struct {
	Id    string
	Job   *Job
	Time  TimePair
	Items []RunReportItem
}

func (*RunReport) Duration

func (r *RunReport) Duration() time.Duration

func (*RunReport) Finalize

func (r *RunReport) Finalize()

func (*RunReport) Initialize

func (r *RunReport) Initialize(job *Job, nodeCount int)

func (*RunReport) Success

func (r *RunReport) Success() bool

func (*RunReport) ToJson

func (r *RunReport) ToJson() RunReportJson

type RunReportItem

type RunReportItem struct {
	Id      string
	Time    TimePair
	Success bool
	Output  string
	Node    *Node
}

func (*RunReportItem) Duration

func (i *RunReportItem) Duration() time.Duration

func (*RunReportItem) Summary

func (i *RunReportItem) Summary() string

func (*RunReportItem) ToJson

func (i *RunReportItem) ToJson() RunReportItemJson

type RunReportItemJson

type RunReportItemJson struct {
	Time     TimePairJson `json:"time"`
	Duration DurationJson `json:"duration"`
	Success  bool         `json:"success"`
	Output   string       `json:"output"`
	Node     string       `json:"node"`
}

type RunReportJson

type RunReportJson struct {
	Job      string              `json:"job"`
	Time     TimePairJson        `json:"time"`
	Duration DurationJson        `json:"duration"`
	Success  bool                `json:"success"`
	Items    []RunReportItemJson `json:"items"`
}

type ShellCommand

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

func (ShellCommand) Command

func (s ShellCommand) Command() []string

type TimePair

type TimePair struct {
	Start time.Time
	Stop  time.Time
}

func (*TimePair) ToJson

func (t *TimePair) ToJson() TimePairJson

type TimePairJson

type TimePairJson struct {
	Start string `json:"start"`
	Stop  string `json:"stop"`
}

Jump to

Keyboard shortcuts

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