services

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Actions []*structures.Action
View Source
var Metrics []*structures.Metric

Functions

func AddAction

func AddAction(action *structures.Action)

AddAction add an action to global Actions array

func AddMetric

func AddMetric(metric *structures.Metric)

AddMetric to global metrics array

func AttachHandler

func AttachHandler(newHandler func())

AttachHandler add a handler for each loop before preparing metrics

func CallAction

func CallAction(name string, payload map[string]interface{}) *string

CallAction with specific name (like pmx)

func GetMetricsAsMap

func GetMetricsAsMap() map[string]*structures.Metric

GetMetricsAsMap prepare metrics before sending

Types

type Endpoints

type Endpoints struct {
	WS string `json:"ws"`
}

Endpoints list of api.cloud.pm2.io

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

Jump to

Keyboard shortcuts

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