Documentation
¶
Index ¶
- Variables
- func AddAction(action *structures.Action)
- func AddMetric(metric *structures.Metric)
- func AttachHandler(newHandler func())
- func CallAction(name string, payload map[string]interface{}) *string
- func GetMetricsAsMap() map[string]*structures.Metric
- type Endpoints
- type Message
- type PayLoad
- type Transporter
- func (transporter *Transporter) CloseAndReconnect()
- func (transporter *Transporter) Connect()
- func (transporter *Transporter) GetServer() *string
- func (transporter *Transporter) GetWsNode() *string
- func (transporter *Transporter) IsConnected() bool
- func (transporter *Transporter) MessagesHandler()
- func (transporter *Transporter) Send(channel string, data interface{})
- func (transporter *Transporter) SendJson(msg interface{})
- func (transporter *Transporter) SetHandlers()
- type Verify
- type VerifyData
- type VerifyResponse
Constants ¶
This section is empty.
Variables ¶
var Actions []*structures.Action
var Metrics []*structures.Metric
Functions ¶
func AddAction ¶
func AddAction(action *structures.Action)
AddAction add an action to global Actions array
func AttachHandler ¶
func AttachHandler(newHandler func())
AttachHandler add a handler for each loop before preparing metrics
func CallAction ¶
CallAction with specific name (like pmx)
func GetMetricsAsMap ¶
func GetMetricsAsMap() map[string]*structures.Metric
GetMetricsAsMap prepare metrics before sending
Types ¶
type Message ¶
type Message struct { Payload interface{} `json:"payload"` Channel string `json:"channel"` }
Message receive from KM
type PayLoad ¶
type PayLoad struct { At int64 `json:"at"` Data interface{} `json:"data"` Process structures.Process `json:"process,omitempty"` Active bool `json:"active"` ServerName string `json:"server_name"` InternalIP string `json:"internal_ip"` Protected bool `json:"protected"` RevCon bool `json:"rev_con"` }
PayLoad is structure for receiving json data
type Transporter ¶
type Transporter struct { Config *structures.Config Version string // contains filtered or unexported fields }
Transporter handle, send and receive packet from KM
func NewTransporter ¶
func NewTransporter(config *structures.Config, version string) *Transporter
NewTransporter with default values
func (*Transporter) CloseAndReconnect ¶
func (transporter *Transporter) CloseAndReconnect()
CloseAndReconnect webSocket
func (*Transporter) Connect ¶
func (transporter *Transporter) Connect()
Connect to current wsNode with headers and prepare handlers/tickers
func (*Transporter) GetServer ¶
func (transporter *Transporter) GetServer() *string
GetServer check api.cloud.pm2.io to get current node
func (*Transporter) GetWsNode ¶
func (transporter *Transporter) GetWsNode() *string
GetWsNode export current node
func (*Transporter) IsConnected ¶
func (transporter *Transporter) IsConnected() bool
IsConnected expose if everything is running normally
func (*Transporter) MessagesHandler ¶
func (transporter *Transporter) MessagesHandler()
MessagesHandler from KM
func (*Transporter) Send ¶
func (transporter *Transporter) Send(channel string, data interface{})
Send to specified channel
func (*Transporter) SendJson ¶
func (transporter *Transporter) SendJson(msg interface{})
SendJson marshal it and check errors
func (*Transporter) SetHandlers ¶
func (transporter *Transporter) SetHandlers()
SetHandlers for messages and pinger ticker
type Verify ¶
type Verify struct { PublicId string `json:"public_id"` PrivateId string `json:"private_id"` Data VerifyData `json:"data"` }
Verify is the object send to api.cloud.pm2.io to get a node to connect
type VerifyData ¶
type VerifyData struct { MachineName string `json:"MACHINE_NAME"` Cpus int `json:"CPUS"` //nb thread Memory uint64 `json:"MEMORY"` //bytes Pm2Version string `json:"PM2_VERSION"` Hostname string `json:"HOSTNAME"` }
VerifyData is a part of Verify
type VerifyResponse ¶
type VerifyResponse struct {
Endpoints Endpoints `json:"endpoints"`
}
VerifyResponse is the object sent by api.cloud.pm2.io