pct

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2014 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_BASEDIR    = "/usr/local/percona/percona-agent"
	CONFIG_FILE_SUFFIX = ".conf"
	// Relative to Basedir.path:
	CONFIG_DIR      = "config"
	DATA_DIR        = "data"
	BIN_DIR         = "bin"
	START_LOCK_FILE = "start.lock"
)

Variables

View Source
var Basedir basedir
View Source
var PublicKey = []byte(`-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA3Ks0r5mrqcxOj95VLyCC
JGkilUyyqIwK9YANtf1qOghQHM4qR1g22c+4iLalzcKuf7fRFWyEOmthUMJEdaPN
k3bHTvqBOVsKigq1Yjydlrk3uIvCBLA37HbHKqM7Uq3vPG25GGxv3wI6NbS1fJOO
VnX0gUYTEiQrbv5OjSBBX/A1mj2RBbSVmHbRSwogFGrxEcz+cn8ulDp+8BOtUHmj
/4FY4IXjeLHihBv/q4TQrO3m0CSig3hmfPJiGpWFdxO5dldb8HN1L+P2EsI6xSxo
5Rk48UbIRBgZjZKQcRCacM0V4Co+HxmtXQkrNIf7jdX6iYXPUD/c8+k7rM1eLgEQ
5jNKQEAiLBdB8ZhDtA4MgFHu8ygwEdYtydo0zLqU0EmtpdmUqnVidudaqVFSiC2Q
KAlH5+r/arnC47cwxa4XletbFzEUcw8sC8ZeqWRSC4EGBJI3fgxoikXsarDQ+uoo
9Hy7jB6XbSGgOJE8Spw3q39DQsB2l7sBliEvi5cl1svRMwrNrTd4A2juAze/GQ+B
tqLJb/FMM1F7LaCl8nLDTf1jPav1/BN5u2y893gX8e48MyUaDtzdiT5HMzMaGkIc
IaY4e/7W5A+S1qCWV0AXTawBgcorRCnUucIjrq6canVZj7BdZpADysRzMib8fS8O
3ca1+bu7FtdcwOTpZusdRfUCAwEAAQ==
-----END PUBLIC KEY-----`)

Functions

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 Ping

func Ping(hostname, apiKey string) (int, error)

func RemoveFile

func RemoveFile(file string) error

func SameFile

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

func TimeoutDialer

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

func URL

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

func VersionStringToInts

func VersionStringToInts(version string) (int64, int64, int64)

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) ApiKey

func (a *API) ApiKey() string

func (*API) Connect

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

func (*API) Get

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

func (*API) Hostname

func (a *API) Hostname() string

func (*API) Origin

func (a *API) Origin() string

func (*API) Post

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

func (*API) Put

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

type APIConnector

type APIConnector interface {
	Connect(hostname, apiKey, agentUuid string) error
	Get(apiKey, url string) (int, []byte, error)
	Post(apiKey, url string, data []byte) (*http.Response, []byte, error)
	Put(apiKey, url string, data []byte) (*http.Response, []byte, error)
	EntryLink(resource string) string
	AgentLink(resource string) string
	Origin() string
	Hostname() string
	ApiKey() string
	AgentUuid() string
}

type Backoff

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

func NewBackoff

func NewBackoff(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 DuplicateServiceInstanceError

type DuplicateServiceInstanceError struct {
	Service string
	Id      uint
}

func (DuplicateServiceInstanceError) Error

type InvalidServiceInstanceError

type InvalidServiceInstanceError struct {
	Service string
	Id      uint
}

func (InvalidServiceInstanceError) Error

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)
	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 UnknownServiceInstanceError

type UnknownServiceInstanceError struct {
	Service string
	Id      uint
}

func (UnknownServiceInstanceError) Error

type Updater

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

func NewUpdater

func NewUpdater(logger *Logger, api APIConnector, pubKey []byte, currentBin, currentVersion string) *Updater

func (*Updater) Check

func (u *Updater) Check() (string, string, error)

func (*Updater) Update

func (u *Updater) Update(version string) error

type WebsocketClient

type WebsocketClient interface {
	Connect()
	ConnectOnce() error
	Disconnect() error
	Status() map[string]string

	// Channel interface:
	Start()
	Stop()
	SendChan() chan *proto.Reply
	RecvChan() chan *proto.Cmd
	ConnectChan() chan bool
	ErrorChan() chan error

	// Direct interface:
	SendBytes(data []byte) error
	Send(data interface{}, timeout uint) error
	Recv(data interface{}, timeout uint) error
	Conn() *websocket.Conn
}

Jump to

Keyboard shortcuts

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