pct

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2016 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_BASEDIR      = "/usr/local/percona/qan-agent"
	CONFIG_FILE_SUFFIX   = ".conf"
	INSTANCE_FILE_SUFFIX = ".json"
	// Relative to Basedir.path:
	CONFIG_DIR   = "config"
	INSTANCE_DIR = "instance"
	DATA_DIR     = "data"
	BIN_DIR      = "bin"
	TRASH_DIR    = "trash"
	START_LOCK   = "start.lock"
	START_SCRIPT = "start.sh"
)

Variables

View Source
var Basedir basedir
View Source
var ErrNoSystemTree error = errors.New("No local system tree file")

Functions

func AtLeastVersion

func AtLeastVersion(v1, v2 string) (bool, error)

func Bytes

func Bytes(bytes uint64) string

func Duration

func Duration(s float64) string

func FileExists

func FileExists(file string) bool

func FileSize

func FileSize(fileName string) (int64, error)

func MakeDir

func MakeDir(dir string) error

func MakeStartLock

func MakeStartLock() error

func Mbps

func Mbps(bytes uint64, seconds float64) string

func Ping

func Ping(hostname string, headers map[string]string) (int, error)

func RemoveFile

func RemoveFile(file string) error

func SameFile

func SameFile(file1, file2 string) (bool, error)

func TimeString

func TimeString(t time.Time) string

func TimeoutDialer

func TimeoutDialer(config *TimeoutClientConfig) func(net, addr string) (c net.Conn, err error)

func ToBool

func ToBool(s string) bool

func URL

func URL(hostname string, paths ...string) string

func WaitStartLock

func WaitStartLock() error

Types

type API

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

func NewAPI

func NewAPI() *API
func (a *API) AgentLink(resource string) string

func (*API) AgentUuid

func (a *API) AgentUuid() string

func (*API) Connect

func (a *API) Connect(hostname, agentUuid string) error

func (*API) CreateInstance

func (a *API) CreateInstance(url string, in interface{}) (bool, error)
func (a *API) EntryLink(resource string) string

func (*API) Get

func (a *API) Get(url string) (int, []byte, error)

func (*API) Hostname

func (a *API) Hostname() string

func (*API) Init

func (a *API) Init(hostname string, headers map[string]string) (int, error)

func (*API) Origin

func (a *API) Origin() string

func (*API) Post

func (a *API) Post(url string, data []byte) (*http.Response, []byte, error)

func (*API) Put

func (a *API) Put(url string, data []byte) (*http.Response, []byte, error)

func (*API) URL

func (a *API) URL(paths ...string) string

type APIConnector

type APIConnector interface {
	Connect(hostname, agentUuid string) error
	Init(hostname string, headers map[string]string) (code int, err error)
	Get(url string) (int, []byte, error)
	Post(url string, data []byte) (*http.Response, []byte, error)
	Put(url string, data []byte) (*http.Response, []byte, error)
	CreateInstance(url string, it interface{}) (bool, error)
	EntryLink(resource string) string
	AgentLink(resource string) string
	Origin() string
	Hostname() string
	AgentUuid() string
	URL(paths ...string) string
}

type Backoff

type Backoff struct {
	NowFunc func() time.Time
	// contains filtered or unexported fields
}

func NewBackoff

func NewBackoff(maxWait int, resetAfter time.Duration) *Backoff

func (*Backoff) Success

func (b *Backoff) Success()

func (*Backoff) Wait

func (b *Backoff) Wait() time.Duration

type CmdRejectedError

type CmdRejectedError struct {
	Cmd    string
	Reason string
}

func (CmdRejectedError) Error

func (e CmdRejectedError) Error() string

type CmdTimeoutError

type CmdTimeoutError struct {
	Cmd string
}

func (CmdTimeoutError) Error

func (e CmdTimeoutError) Error() string

type InvalidInstanceError

type InvalidInstanceError struct {
	UUID string
}

func (InvalidInstanceError) Error

func (e InvalidInstanceError) Error() string

type Logger

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

func NewLogger

func NewLogger(logChan chan proto.LogEntry, service string) *Logger

func (*Logger) Debug

func (l *Logger) Debug(entry ...interface{})

func (*Logger) DebugOffline

func (l *Logger) DebugOffline(entry ...interface{})

func (*Logger) Error

func (l *Logger) Error(entry ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(entry ...interface{})

func (*Logger) Info

func (l *Logger) Info(entry ...interface{})

func (*Logger) LogChan

func (l *Logger) LogChan() chan proto.LogEntry

func (*Logger) Service

func (l *Logger) Service() string

func (*Logger) Warn

func (l *Logger) Warn(entry ...interface{})

type PidFile

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

func NewPidFile

func NewPidFile() *PidFile

func (*PidFile) Get

func (p *PidFile) Get() string

func (*PidFile) Remove

func (p *PidFile) Remove() error

func (*PidFile) Set

func (p *PidFile) Set(pidFile string) error

type QueueFullError

type QueueFullError struct {
	Cmd  string
	Name string
	Size uint
}

func (QueueFullError) Error

func (e QueueFullError) Error() string

type ServiceIsNotRunningError

type ServiceIsNotRunningError struct {
	Service string
}

func (ServiceIsNotRunningError) Error

func (e ServiceIsNotRunningError) Error() string

type ServiceIsRunningError

type ServiceIsRunningError struct {
	Service string
}

func (ServiceIsRunningError) Error

func (e ServiceIsRunningError) Error() string

type ServiceManager

type ServiceManager interface {
	Start() error
	Stop() error
	Status() map[string]string
	GetConfig() ([]proto.AgentConfig, []error)
	GetDefaults() map[string]interface{}
	Handle(cmd *proto.Cmd) *proto.Reply
}

type Status

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

func NewStatus

func NewStatus(procs []string) *Status

func (*Status) All

func (s *Status) All() map[string]string

func (*Status) Get

func (s *Status) Get(proc string) string

func (*Status) Merge

func (s *Status) Merge(others ...map[string]string) map[string]string

func (*Status) Update

func (s *Status) Update(proc string, status string)

func (*Status) UpdateRe

func (s *Status) UpdateRe(proc string, status string, cmd *proto.Cmd)

type StatusReporter

type StatusReporter interface {
	Status() map[string]string
}

type SyncChan

type SyncChan struct {
	StartChan chan bool
	StopChan  chan bool
	DoneChan  chan bool
	CrashChan chan bool
	Crash     bool
}

func NewSyncChan

func NewSyncChan() *SyncChan

func (*SyncChan) Done

func (sync *SyncChan) Done()

func (*SyncChan) Graceful

func (sync *SyncChan) Graceful()

func (*SyncChan) IsGraceful

func (sync *SyncChan) IsGraceful() bool

func (*SyncChan) Start

func (sync *SyncChan) Start() bool

func (*SyncChan) Stop

func (sync *SyncChan) Stop()

func (*SyncChan) Wait

func (sync *SyncChan) Wait()

type TimeoutClientConfig

type TimeoutClientConfig struct {
	ConnectTimeout   time.Duration
	ReadWriteTimeout time.Duration
}

type UnknownCmdError

type UnknownCmdError struct {
	Cmd string
}

func (UnknownCmdError) Error

func (e UnknownCmdError) Error() string

type UnknownServiceError

type UnknownServiceError struct {
	Service string
}

func (UnknownServiceError) Error

func (e UnknownServiceError) Error() string

type WebsocketClient

type WebsocketClient interface {
	Conn() *websocket.Conn
	Status() map[string]string

	// Cmd/Reply chans:
	Start()                      // start the send/recv chans
	Stop()                       // stop the send/recv chans manually
	RecvChan() chan *proto.Cmd   // get the (recv) cmdChan
	SendChan() chan *proto.Reply // get the (send) replyChan

	// Async connect:
	Connect()               // try forever to connect, notify via ConnectChan
	Disconnect() error      // disconnect manually, notify via ConnectChan
	ConnectChan() chan bool // true on connect, false on disconnect
	ErrorChan() chan error  // get err from send/recv chans

	// Sync connect:
	ConnectOnce(timeout uint) error
	DisconnectOnce() error

	// Data transfer:
	SendBytes(data []byte, timeout uint) error // send data (data/sender)
	Recv(data interface{}, timeout uint) error // recv proto.Response (data/sender)
	Send(data interface{}, timeout uint) error // send proto.LogEntry (log/relay)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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