client

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandsQueue = "core:default"

	ResultNoTimeout      = 0
	ResultDefaultTimeout = 10
)
View Source
const (
	//StateSuccess successs exit status
	StateSuccess = State("SUCCESS")

	//StateError error exist status
	StateError = State("ERROR")

	//StateTimeout timeout exit status
	StateTimeout = State("TIMEOUT")

	//StateKilled killed exit status
	StateKilled = State("KILLED")

	//StateUnknownCmd unknown cmd exit status
	StateUnknownCmd = State("UNKNOWN_CMD")

	//StateDuplicateID dublicate id exit status
	StateDuplicateID = State("DUPILICATE_ID")

	LevelJson = 20
)

Variables

View Source
var (
	NotFound = fmt.Errorf("not found")
)

Functions

func NewPool

func NewPool(address, password string) *redis.Pool

Types

type A

type A map[string]interface{}

type AggregatorManager

type AggregatorManager interface {
	Query() (interface{}, error)
}

func Aggregator

func Aggregator(cl Client) AggregatorManager

type AggregatorMgr

type AggregatorMgr struct {
	Client
}

func (*AggregatorMgr) Query

func (b *AggregatorMgr) Query() (interface{}, error)

type BlockDevice

type BlockDevice struct {
	Name       string        `json:"name"`
	Kname      string        `json:"kname"`
	MajMin     string        `json:"maj:min"`
	Fstype     string        `json:"fstype"`
	Mountpoint string        `json:"mountpoint"`
	Label      string        `json:"label"`
	UUID       string        `json:"uuid"`
	Parttype   string        `json:"parttype"`
	Partlabel  string        `json:"partlabel"`
	Partuuid   string        `json:"partuuid"`
	Partflags  string        `json:"partflags"`
	Ra         string        `json:"ra"`
	Ro         string        `json:"ro"`
	Rm         string        `json:"rm"`
	Hotplug    string        `json:"hotplug"`
	Model      string        `json:"model"`
	Serial     string        `json:"serial"`
	Size       string        `json:"size"`
	State      string        `json:"state"`
	Owner      string        `json:"owner"`
	Group      string        `json:"group"`
	Mode       string        `json:"mode"`
	Alignment  string        `json:"alignment"`
	MinIo      string        `json:"min-io"`
	OptIo      string        `json:"opt-io"`
	PhySec     string        `json:"phy-sec"`
	LogSec     string        `json:"log-sec"`
	Rota       string        `json:"rota"`
	Sched      string        `json:"sched"`
	RqSize     string        `json:"rq-size"`
	Type       string        `json:"type"`
	DiscAln    string        `json:"disc-aln"`
	DiscGran   string        `json:"disc-gran"`
	DiscMax    string        `json:"disc-max"`
	DiscZero   string        `json:"disc-zero"`
	Wsame      string        `json:"wsame"`
	Wwn        string        `json:"wwn"`
	Rand       string        `json:"rand"`
	Pkname     string        `json:"pkname"`
	Hctl       string        `json:"hctl"`
	Tran       string        `json:"tran"`
	Subsystems string        `json:"subsystems"`
	Rev        string        `json:"rev"`
	Vendor     string        `json:"vendor"`
	Children   []BlockDevice `json:"children"`
}

type BtrfsFS

type BtrfsFS struct {
	Label        string        `json:"label"`
	UUID         string        `json:"uuid"`
	TotalDevices int           `json:"total_devices"`
	Used         int64         `json:"used"`
	Devices      []btrfsDevice `json:"devices"`
}

type BtrfsManager

type BtrfsManager interface {
	List() ([]BtrfsFS, error)
}

func Btrfs

func Btrfs(cl Client) BtrfsManager

type CPUStats

type CPUStats struct {
	GuestNice float64 `json:"guestnice"`
	Idle      float64 `json:"idle"`
	IoWait    float64 `json:"iowait"`
	Irq       float64 `json:"irq"`
	Nice      float64 `json:"nice"`
	SoftIrq   float64 `json:"softirq"`
	Steal     float64 `json:"steal"`
	Stolen    float64 `json:"stolen"`
	System    float64 `json:"system"`
	User      float64 `json:"user"`
}

type Client

type Client interface {
	Raw(command string, args A, opts ...Option) (JobId, error)
	Result(job JobId, timeout ...int) (*Result, error)
	Exists(job JobId) bool
	ResultNonBlock(job JobId) (*Result, error)
}

func NewClient

func NewClient(address, password string) Client

func NewClientWithPool

func NewClientWithPool(pool *redis.Pool) Client

type Command

type Command struct {
	ID              string `json:"id"`
	Command         string `json:"command"`
	Arguments       A      `json:"arguments"`
	Queue           string `json:"queue"`
	StatsInterval   int    `json:"stats_interval,omitempty"`
	MaxTime         int    `json:"max_time,omitempty"`
	MaxRestart      int    `json:"max_restart,omitempty"`
	RecurringPeriod int    `json:"recurring_period,omitempty"`
	LogLevels       []int  `json:"log_levels,omitempty"`
	Tags            Tags   `json:"tags"`
}

type ContainerCreateAguments

type ContainerCreateAguments struct {
	Root        string            `json:"root"`         //Root plist
	Mount       map[string]string `json:"mount"`        //data disk mounts.
	HostNetwork bool              `json:"host_network"` //share host networking stack
	Nics        []Nic             `json:"nics"`         //network setup (only respected if HostNetwork is false)
	Port        map[int]int       `json:"port"`         //port forwards (only if default networking is enabled)
	Hostname    string            `json:"hostname"`     //hostname
	Storage     string            `json:"storage"`      //ardb storage needed for g8ufs mounts.
	Tags        []string          `json:"tags"`         //for searching containers
}

type ContainerInfo

type ContainerInfo struct {
	Arguments ContainerCreateAguments `json:"arguments"`
	Pid       int                     `json:"pid"`
	Root      string                  `json:"root"`
}

type ContainerManager

type ContainerManager interface {
	Client(id int) Client
	List() (map[int16]ContainerResult, error)
}

func Container

func Container(cl Client) ContainerManager

type ContainerResult

type ContainerResult struct {
	Container ContainerInfo `json:"container"`
	CPU       int           `json:"cpu"`
	Swap      int           `json:"swap"`
	RSS       int           `json:"ress"`
}

type CoreManager

type CoreManager interface {
	System(cmd string, env map[string]string, cwd string, stdin string, opt ...Option) (JobId, error)
	SystemArgs(cmd string, args []string, env map[string]string, cwd string, stdin string, opt ...Option) (JobId, error)
	Bash(bash string, stdin string, opt ...Option) (JobId, error)
	Ping() error
	Jobs() ([]Job, error)
	Job(job JobId) (*Job, error)
	KillJob(job JobId, signal syscall.Signal) error
	KillAllJobs() error
	Process(pid ProcessId) (*Process, error)
	ProcessAlive(pid ProcessId) (bool, error)
	Processes() ([]Process, error)
	KillProcess(pid ProcessId, signal syscall.Signal) error
	State() (*JobStats, error)
}

func Core

func Core(client Client) CoreManager

type DiskManager

type DiskManager interface {
	List() (Disks, error)
}

func Disk

func Disk(cl Client) DiskManager

type DiskStats

type DiskStats struct {
	RdBytes uint64 `json:"rdbytes"`
	RdTimes uint64 `json:"rdtimes"`
	WrBytes uint64 `json:"wrbytes"`
	WrTimes uint64 `json:"wrtimes"`
}

type Disks

type Disks struct {
	BlockDevices []BlockDevice `json:"blockdevices"`
}

type File

type File string

type FilesystemManager

type FilesystemManager interface {
	Upload(reader io.Reader, p string) error
	Download(p string, writer io.Writer) error
	Remove(p string) error
	Exists(p string) (bool, error)
}

func Filesystem

func Filesystem(client Client) FilesystemManager

type InfoManager

type InfoManager interface {
	CPU() ([]cpu.InfoStat, error)
	Mem() (mem.VirtualMemoryStat, error)
	Nic() ([]net.InterfaceStat, error)
	Disk() ([]disk.PartitionStat, error)
	OS() (host.InfoStat, error)
}

func Info

func Info(cl Client) InfoManager

type Job

type Job struct {
	Command   Command `json:"cmd"`
	CPU       float64 `json:"cpu"`
	RSS       int64   `json:"rss"`
	Swap      int64   `json:"swap"`
	VMS       int64   `json:"vms"`
	StartTime int64   `json:"starttime"`
}

type JobId

type JobId string

type JobStats

type JobStats struct {
	CPU   float64 `json:"cpu"`
	RSS   uint64  `json:"rss"`
	VMS   uint64  `json:"vms"`
	Swap  uint64  `json:"swap"`
	Debug string  `json:"debug,ommitempty"`
}

type KvmManager

type KvmManager interface {
	List() ([]VM, error)
	InfoPs(uuid string) (VMInfo, error)
}

func Kvm

func Kvm(cl Client) KvmManager

type Network

type Network struct {
	RxBytes uint64 `json:"rxbytes"`
	RxPkts  uint64 `json:"rxpkts"`
	TxBytes uint64 `json:"txbytes"`
	TxPkts  uint64 `json:"txpkts"`
}

type NetworkConfig

type NetworkConfig struct {
	Dhcp    bool     `json:"dhcp"`
	CIDR    string   `json:"cidr"`
	Gateway string   `json:"gateway"`
	DNS     []string `json:"dns"`
}

type Nic

type Nic struct {
	Type      string        `json:"type"`
	ID        string        `json:"id"`
	HWAddress string        `json:"hwaddr"`
	Config    NetworkConfig `json:"config"`
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

func ID

func ID(id string) Option

func MaxRestart

func MaxRestart(restart int) Option

func MaxTime

func MaxTime(timeout int) Option

func Queue

func Queue(queue string) Option

func RecurringPeriod

func RecurringPeriod(period int) Option

type Process

type Process struct {
	Command    string    `json:"cmdline"`
	Createtime uint64    `json:"createtime"`
	Cpu        CPUStats  `json:"cpu"`
	PID        ProcessId `json:"pid"`
	PPID       ProcessId `json:"ppid"`
	RSS        uint64    `json:"rss"`
	Swap       uint64    `json:"swap"`
	VMS        uint64    `json:"vms"`
}

type ProcessId

type ProcessId uint64

type Result

type Result struct {
	ID        string  `json:"id"`
	Command   string  `json:"command"`
	Data      string  `json:"data"`
	Streams   Streams `json:"streams,omitempty"`
	Critical  string  `json:"critical,omitempty"`
	Level     int     `json:"level"`
	State     State   `json:"state"`
	Code      uint32  `json:"code"`
	StartTime int64   `json:"starttime"`
	Time      int64   `json:"time"`
	Tags      string  `json:"tags"`
	Container uint64  `json:"container"`
}

func (*Result) Json

func (r *Result) Json(v interface{}) error

type State

type State string

type Streams

type Streams []string

func (Streams) Stderr

func (s Streams) Stderr() string

func (Streams) Stdout

func (s Streams) Stdout() string

func (Streams) String

func (s Streams) String() string

type Tags

type Tags []string

type VCpu

type VCpu struct {
	State float64 `json:"state"`
	Time  float64 `json:"time"`
}

type VM

type VM struct {
	ID    uint64 `json:"id"`
	Name  string `json:"name"`
	State string `json:"state"`
	UUID  string `json:"uuid"`
}

type VMInfo

type VMInfo struct {
	Block   map[string]DiskStats `json:"block"`
	Network map[string]Network   `json:"net"`
	Vcpu    map[string]VCpu      `json:"vcpu"`
}

type ZerotierItem

type ZerotierItem struct {
	Nwid              string   `json:"nwid"`
	Name              string   `json:"name"`
	Status            string   `json:"status"`
	Type              string   `json:"type"`
	AllowDefault      bool     `json:"allowDefault"`
	AllowGlobal       bool     `json:"allowGlobal"`
	AllowManaged      bool     `json:"allowManaged"`
	Bridge            bool     `json:"bridge"`
	BroadcastEnabled  bool     `json:"broadcastEnabled"`
	DHCP              bool     `json:"dhcp"`
	ID                string   `json:"id"`
	Mac               string   `json:"mac"`
	Mtu               uint64   `json:"mtu"`
	NetConfRevision   uint64   `json:"netconfRevision"`
	PortDeviceName    string   `json:"portDeviceName"`
	PortError         uint8    `json:"portError"`
	AssignedAddresses []string `json:"assignedAddresses"`
}

type ZerotierManager

type ZerotierManager interface {
	List() ([]ZerotierItem, error)
}

func Zerotier

func Zerotier(cl Client) ZerotierManager

type ZerotierRoute

type ZerotierRoute struct {
	Flags  uint64 `json:"flags"`
	Metric uint64 `json:"metric"`
	Target string `json:"target"`
	Via    string `json:"via"`
}

Jump to

Keyboard shortcuts

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