host

package
v0.0.0-...-ab9d384 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeMessage

func EncodeMessage(msg ControlMessage) []byte

func GetSocketPath

func GetSocketPath() (sockFile string, sockPath string)

func IsLive

func IsLive() bool

func SendCommand

func SendCommand(cmd string, appName string)

func SpawnApp

func SpawnApp(app config.App) (int, error)

Types

type AppStat

type AppStat struct {
	App    string  `json:"app"`
	Uri    string  `json:"uri"`
	Pid    int     `json:"pid"`
	Uptime int     `json:"uptime"`
	Memory float64 `json:"memory"`
	Cpu    float64 `json:"cpu"`
}

type ControlMessage

type ControlMessage struct {
	Cmd   string    `json:"cmd"`
	App   string    `json:"app"`
	MsgId string    `json:"msgId"`
	Text  string    `json:"text"`
	Stat  AppStat   `json:"stat"`
	Stats []AppStat `json:"stats"`
	Error string    `json:"error"`

	// `Pid` shall be provided when `Cmd` is `handshake`.
	Pid int `json:"pid"`

	// `conn.Close()` will destroy the connection before the final message is flushed, causing the
	// other peer losing the connection and the message, and no EOF will be received. To guarantee
	// the final message is sent, we need a signal (`FIN`) to indicate whether this is the final
	// message, and close the connection on the receiver side.
	Fin bool `json:"fin"`
}

func DecodeMessage

func DecodeMessage(packet *[]byte, buf []byte, n int, eof bool) []ControlMessage

type Guest

type Guest struct {
	AppName string
	AppUri  string
	// contains filtered or unexported fields
}

func NewGuest

func NewGuest(app config.App, onStopCommand func(msgId string)) *Guest

func (*Guest) Join

func (self *Guest) Join() error

func (*Guest) Leave

func (self *Guest) Leave(reason string, replyId string)

func (*Guest) Send

func (self *Guest) Send(msg ControlMessage) error

type Host

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

The Host-Guest model is a mechanism used to hold communication between all apps running on the same machine.

This mechanism is primarily used for the CLI tool sending control commands to the apps.

func NewHost

func NewHost(config config.Config) *Host

func (*Host) Start

func (self *Host) Start(wait bool) error

func (*Host) Stop

func (self *Host) Stop()

Jump to

Keyboard shortcuts

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