situation

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2018 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckWatchImpl

func CheckWatchImpl(t *TargetImpl)

func NewImpl

func NewImpl(t *TargetImpl, id int, conf TargetEntry, tasks execution.TaskArray) error

func RecordImpl

func RecordImpl(t *TargetImpl, obsData []byte, obsTime time.Duration) error

func RecvFrom

func RecvFrom(ch *chan string) (string, error)

func StartWatchImpl

func StartWatchImpl(t *TargetImpl, fn func())

func StopWatchImpl

func StopWatchImpl(t *TargetImpl)

Types

type Credentials

type Credentials struct {
	Id   int    `json:"id"   sql:"id INTEGER NOT NULL"`
	Name string `json:"name" sql:"name TEXT NOT NULL"`
	User string `json:"user" sql:"username TEXT NOT NULL"`
	Pass string `json:"pass" sql:"password TEXT NOT NULL"`
	Cert string `json:"cert" sql:"key TEXT NOT NULL"`
}

type CredentialsMap

type CredentialsMap map[string]Credentials

type Situation

type Situation struct {
	Targets     []string       `json:"targets"`
	Definitions TargetMap      `json:"definitions"`
	Credentials CredentialsMap `json:"credentials"`
}

type Target

type Target interface {
	New(id int, conf TargetEntry, t execution.TaskArray) error
	Find() error
	Watch() error
	Report() (*TargetObs, error)
	GetImpl() *TargetImpl
}

type TargetArr

type TargetArr []TargetEntry

type TargetDef

type TargetDef struct {
	Id      int      `json:"id"       sql:"id INTEGER NOT NULL"`
	Name    string   `json:"name"     sql:"-"`
	GroupId int      `json:"group_id" sql:"group_id INTEGER NOT NULL"`
	Addr    string   `json:"addr"     sql:"address TEXT NOT NULL"`
	Cred    string   `json:"cred"     sql:"-"`
	Prot    string   `json:"prot"     sql:"-"`
	Sys     []string `json:"sys"      sql:"-"`
}

type TargetEntry

type TargetEntry struct {
	Target      TargetDef   `json:"target"      sql:"CREATE TABLE IF NOT EXISTS target_definitions"`
	Credentials Credentials `json:"credentials" sql:"CREATE TABLE IF NOT EXISTS target_credentials"`
}

func Parse

func Parse(situ *Situation) ([]TargetEntry, error)

type TargetExec

type TargetExec struct {
	Impl TargetImpl
}

func (TargetExec) Find

func (t TargetExec) Find() error

func (*TargetExec) GetImpl

func (t *TargetExec) GetImpl() *TargetImpl

func (*TargetExec) New

func (t *TargetExec) New(id int, conf TargetEntry, tasks execution.TaskArray) error

func (*TargetExec) Report

func (t *TargetExec) Report() (*TargetObs, error)

func (TargetExec) Watch

func (t TargetExec) Watch() error

type TargetGroup

type TargetGroup struct {
	Id     int      `json:"id"      sql:"id INTEGER NOT NULL"`
	Name   string   `json:"name"    sql:"name TEXT NOT NULL"`
	Addr   []string `json:"addr"    sql:"-"`
	CredId int      `json:"cred_id" sql:"credential_id INTEGER NOT NULL"`
	Cred   string   `json:"cred"    sql:"-"`
	Prot   string   `json:"prot"    sql:"protocol TEXT NOT NULL"`
	Sys    []string `json:"sys"     sql:"system TEXT NOT NULL"`
}

type TargetImpl

type TargetImpl struct {
	Db *global.DbImpl
	Ch *chan string

	Conf        TargetEntry
	CronJob     *cron.Cron
	CronSpec    string
	Id          int
	RecordCache []TargetReport
	Task        execution.TaskArray
	Wait        *sync.WaitGroup
	WatchCount  int64
	WatchLimit  int64
	// contains filtered or unexported fields
}

type TargetInfo

type TargetInfo struct {
	Info []string `json:"info"`
}

type TargetMap

type TargetMap map[string]TargetGroup

type TargetObs

type TargetObs struct {
	Idx int
	Tv  uint64
	Dur string
	Val string
}

func ReportImpl

func ReportImpl(t *TargetImpl) (*TargetObs, error)

type TargetReport

type TargetReport struct {
	ReportId int64   `db:"report_id" sql:"report_id INTEGER NOT NULL"`
	TargetId int64   `db:"target_id" sql:"target_id INTEGER NOT NULL"`
	TaskId   int64   `db:"task_id"   sql:"task_id INTEGER NOT NULL"`
	X_Diff   float64 `db:"x_diff"    sql:"x_diff FLOAT NOT NULL"`
	Y_Diff   float64 `db:"y_diff"    sql:"y_diff FLOAT NOT NULL"`
	Y_Max    float64 `db:"y_max"     sql:"y_max FLOAT NOT NULL"`
	Y_Min    float64 `db:"y_min"     sql:"y_min FLOAT NOT NULL"`
	Y_Rate   float64 `db:"y_rate"    sql:"y_rate FLOAT NOT NULL"`
	X_Val    float64 `db:"x_val"     sql:"x_val FLOAT NOT NULL"`
	Y_Val    float64 `db:"y_val"     sql:"y_val FLOAT NOT NULL"`
}

type TargetSsh

type TargetSsh struct {
	Impl TargetImpl
	// contains filtered or unexported fields
}

func (*TargetSsh) Find

func (t *TargetSsh) Find() error

func (*TargetSsh) GetImpl

func (t *TargetSsh) GetImpl() *TargetImpl

func (*TargetSsh) New

func (t *TargetSsh) New(id int, conf TargetEntry, tasks execution.TaskArray) error

func (*TargetSsh) Report

func (t *TargetSsh) Report() (*TargetObs, error)

func (*TargetSsh) Watch

func (t *TargetSsh) Watch() error

Jump to

Keyboard shortcuts

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