protocols

package module
v0.0.0-...-27e1e90 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 6 Imported by: 8

Documentation

Index

Constants

View Source
const (
	TypeNodeJoin = iota
	TypeNodeJoinResponse
	TypeHeartbeat
	TypeHeartbeatResponse

	TypeFilePush
	TypeFilePushResponse

	TypeFilePull
	TypeFilePullResponse

	TypeFileTree
	TypeFileTreeResponse

	TypeNodeStatus
	TypeNodeStatusResponse

	TypeNodeLog
	TypeNodeLogResponse

	TypeRunCommand
	TypeRunCommandResponse

	TypeRunScript
	TypeRunScriptResponse

	TypeAppCreate
	TypeAppCreateResponse

	TypeAppDelete
	TypeAppDeleteResponse

	TypeAppDeploy
	TypeAppDeployResponse

	TypeAppVersion
	TypeAppVersionResponse

	TypeAppsInfo
	TypeAppsInfoResponse

	TypeAppReset
	TypeAppResetResponse

	TypeAppLatestVersion
	TypeAppLatestVersionResponse

	TypePakmaCommand
	TypePakmaCommandResponse

	TypeSshRegister
	TypeSshRegisterResponse

	TypeSshUnregister
	TypeSshUnregisterResponse

	TypeWaitTask
	TypeWaitTaskResponse

	TypeCancelTask
	TypeCancelTaskResponse

	TypeQueryTask
	TypeQueryTaskResponse

	TypeListTasks
	TypeListTasksResponse

	TypeAppCommit
	TypeAppCommitResponse

	TypeAppInfo
	TypeAppInfoResponse

	TypeUndefined
)
View Source
const (
	NodeStateReady = iota
	NodeStateDisconn
	NodeStateDead
)
View Source
const (
	ConnStateOn = iota
	ConnStateOff
)

Variables

View Source
var MsgTypeString map[int]string = map[int]string{
	TypeNodeJoin:          "NodeJoin",
	TypeNodeJoinResponse:  "NodeJoinResponse",
	TypeHeartbeat:         "Heartbeat",
	TypeHeartbeatResponse: "HeartbeatResponse",

	TypeFilePush:         "FilePush",
	TypeFilePushResponse: "FilePushResponse",

	TypeFilePull:         "TypeFilePull",
	TypeFilePullResponse: "FilePullResponse",

	TypeFileTree:         "FileTree",
	TypeFileTreeResponse: "FileTreeResponse",

	TypeNodeStatus:         "NodeStatus",
	TypeNodeStatusResponse: "NodeStatusResponse",

	TypeNodeLog:         "NodeLog",
	TypeNodeLogResponse: "NodeLogResponse",

	TypeRunCommand:         "RunCommand",
	TypeRunCommandResponse: "RunCommandResponse",

	TypeRunScript:         "RunScript",
	TypeRunScriptResponse: "RunScriptResponse",

	TypeAppCreate:         "AppCreate",
	TypeAppCreateResponse: "AppCreateResponse",

	TypeAppDelete:         "AppDelete",
	TypeAppDeleteResponse: "AppDeleteResponse",

	TypeAppDeploy:         "AppDeploy",
	TypeAppDeployResponse: "AppDeployResponse",

	TypeAppVersion:         "AppVersion",
	TypeAppVersionResponse: "AppVersionResponse",

	TypeAppsInfo:         "AppsInfo",
	TypeAppsInfoResponse: "AppsInfoResponse",

	TypeAppReset:         "AppReset",
	TypeAppResetResponse: "AppResetResponse",

	TypeAppLatestVersion:         "AppLatestVersion",
	TypeAppLatestVersionResponse: "AppLatestVersionResponse",

	TypePakmaCommand:         "TypePakmaCommand",
	TypePakmaCommandResponse: "TypePakmaCommandResponse",

	TypeSshRegister:         "TypeSshRegister",
	TypeSshRegisterResponse: "TypeSshRegisterResponse",

	TypeSshUnregister:         "TypeSshUnregister",
	TypeSshUnregisterResponse: "TypeSshUnregisterResponse",

	TypeWaitTask:         "TypeWaitTask",
	TypeWaitTaskResponse: "TypeWaitTaskResponse",

	TypeCancelTask:         "TypeCancelTask",
	TypeCancelTaskResponse: "TypeCancelTaskResponse",

	TypeQueryTask:         "TypeQueryTask",
	TypeQueryTaskResponse: "TypeQueryTaskResponse",

	TypeListTasks:         "TypeListTasks",
	TypeListTasksResponse: "TypeListTasksResponse",

	TypeAppCommit:         "TypeAppCommit",
	TypeAppCommitResponse: "TypeAppCommitResponse",

	TypeAppInfo:         "TypeAppInfo",
	TypeAppInfoResponse: "TypeAppInfoResponse",
}

Functions

func RecvMessageUnique

func RecvMessageUnique(conn net.Conn) (int, uint32, []byte, error)

func SendMessageUnique

func SendMessageUnique(conn net.Conn, mtype int, serial uint32, raw []byte) error

Types

type ApiStat

type ApiStat struct {
	Requests int `json:"requests"`
	Success  int `json:"success"`
}

type BrainInfo

type BrainInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Addr    string `json:"addr"`
}

type BrainInfoText

type BrainInfoText struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Addr    string `json:"addr"`
}

type CommandParams

type CommandParams struct {
	Command    string
	Background bool
	DelayTime  int
	ExecTs     int64
	NeedAlign  bool
}

type ExecStatus

type ExecStatus int
const (
	ExecOK ExecStatus = iota
	ExecCommunicationError
	ExecProcessError
)

type ExecutionResult

type ExecutionResult struct {
	Name                  string
	Code                  ExecStatus
	CommunicationErrorMsg string
	ProcessErrorMsg       string
	Result                string
	ResultCompatible      string
}

type ExecutionResults

type ExecutionResults []ExecutionResult

func (*ExecutionResults) ToText

func (results *ExecutionResults) ToText() *ExecutionResultsText

type ExecutionResultsText

type ExecutionResultsText struct {
	Results            ExecutionResults
	Total              int
	Success            int
	CommunicationError int
	ProcessError       int
}

type FileDistribParams

type FileDistribParams struct {
	LocalFile   string
	TargetPath  string
	TargetNodes []string
}

type FileParams

type FileParams struct {
	PackName    string
	TargetPath  string
	FileBuf     string
	ForceCreate bool
}

type FilePullParams

type FilePullParams struct {
	PackName   string
	PathType   string
	TargetPath string
	FileBuf    string
}

type FileSpreadParams

type FileSpreadParams struct {
	TargetPath  string
	FileOrDir   string
	TargetNodes []string
}

type GroupInfo

type GroupInfo struct {
	Name  string   `json:"name" binding:"required"`
	Nodes []string `json:"nodes" binding:"required"`
	// NoCheck can be in request
	NoCheck bool `json:"nocheck" binding:"omitempty"`

	// Size and Unhealthy will be in response
	Size      int      `json:"size" binding:"omitempty"`
	Unhealthy []string `json:"unhealthy" binding:"omitempty"`
}

type HeartBeatRequest

type HeartBeatRequest struct {
	Num   uint32 `json:"num"`
	Delay int64  `json:"delay"`
}

type HeartBeatResponse

type HeartBeatResponse struct {
	NewNum      uint32 `json:"new_num"`
	Ts          int64  `json:"ts"`
	IsMsgConnOn bool   `json:"is_msgconn_on"`
}

type ListQueryParam

type ListQueryParam struct {
	Match  string `form:"match" json:"match" binding:"omitempty"`
	Method string `form:"method" json:"method" binding:"oneof=prefix suffix contain equal all"`
}

type LogParams

type LogParams struct {
	MaxLines      int
	MaxDaysBefore int
	Logs          []string
}

type NameServiceEntry

type NameServiceEntry struct {
	Key         string `json:"key"`
	Type        string `json:"type" binding:"oneof=addr num str array"`
	Value       string `json:"value"`
	Description string `json:"description" binding:"omitempty"`
	TTL         int    `json:"ttl,omitempty" binding:"omitempty"`
}

type NodeInfo

type NodeInfo struct {
	Name      string
	Version   string
	Addr      string
	State     int32
	ConnState int32
	Delay     int64
	OnlineTs  int64
	OfflineTs int64
	ActiveTs  int64
	BrainTs   int64
}

func (*NodeInfo) ToText

func (node *NodeInfo) ToText() *NodeInfoText

type NodeInfoText

type NodeInfoText struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Addr        string `json:"addr"`
	State       string `json:"state"`
	Delay       string `json:"delay"`
	OnlineTime  string `json:"online_time,omitempty"`
	OfflineTime string `json:"offline_time,omitempty"`
	LastOnline  string `json:"last_active,omitempty"`
}

type NodeJoinInfo

type NodeJoinInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Addr    string `json:"addr"`
}

type NodeJoinResponse

type NodeJoinResponse struct {
	Ts     int64  `json:"ts"`
	NewNum uint32 `json:"new_num"`
}

type NodeParseResult

type NodeParseResult struct {
	OutputNames    []string
	InvalidNames   []string
	UnhealthyNodes []string
}

type NodesInfo

type NodesInfo struct {
	BrainName    string
	BrainVersion string
	BrainAddr    string
	InfoList     []NodeInfo
}

func (*NodesInfo) ToText

func (nodes *NodesInfo) ToText() *NodesInfoText

type NodesInfoText

type NodesInfoText struct {
	BrainInfo    BrainInfoText   `json:"brain"`
	NodeInfoList []*NodeInfoText `json:"nodes"`
	Total        int             `json:"total"`
	Online       int             `json:"online"`
	Offline      int             `json:"offline"`
}

type NodesStatus

type NodesStatus struct {
	StatusList []Status
}

func (*NodesStatus) ToText

func (status *NodesStatus) ToText() *NodesStatusText

type NodesStatusText

type NodesStatusText struct {
	NodesStatusList []*StatusText `json:"nodes"`
	AvrCpuLoad      string        `json:"average_cpuload"`
	AvrMemoryUsage  string        `json:"average_memoryusage"`
	AvrDiskUsage    string        `json:"average_diskusage"`
}

type ProxyMsg

type ProxyMsg struct {
	Code int
	Msg  string
	Data string
}

type Response

type Response struct {
	Message   string            `json:"msg,omitempty"`
	NameEntry *NameServiceEntry `json:"entry,omitempty"`
	NameList  []string          `json:"list,omitempty"`
}

type Result

type Result struct {
	// Result code. Reserved
	Rcode int

	// Result msg string. OK, or Error Reason
	Rmsg string

	// For script or command execution. Script output.
	Output string

	// For version control. Version hash code.
	Version string

	// For version control. Modified flag.
	Modified bool
}

type SSHInfo

type SSHInfo struct {
	Ip       string
	Port     uint32
	Username string
	Password string
}

type SSHInfoDump

type SSHInfoDump struct {
	Name     string
	Username string
	Password string
	Ip       string
	Port     uint32
}

type ScriptParams

type ScriptParams struct {
	FileName   string
	TargetPath string
	FileBuf    string
	DelayTime  int
	ExecTs     int64
	NeedAlign  bool
}

type Status

type Status struct {
	Name      string
	Platform  string
	CpuCores  int
	LocalTime time.Time

	CpuLoadShort float64
	CpuLoadLong  float64
	MemUsed      uint64
	MemTotal     uint64
	DiskUsed     uint64
	DiskTotal    uint64
}

func (*Status) ToText

func (status *Status) ToText() *StatusText

type StatusText

type StatusText struct {
	Name         string `json:"name"`
	Platform     string `json:"platform"`
	CpuCores     int    `json:"cpu_cores"`
	LocalTime    string `json:"local_time"`
	CpuLoadShort string `json:"cpu_average1"`
	CpuLoadLong  string `json:"cpu_average10"`
	MemUsage     string `json:"memory_usage"`
	DiskUsage    string `json:"disk_usage"`
}

type Summary

type Summary struct {
	TotalRequests int                 `json:"total_request"`
	Since         int64               `json:"since"`
	ApiStats      map[string]*ApiStat `json:"api_stats"`
}

type WorkgroupChildren

type WorkgroupChildren []string

type WorkgroupInfo

type WorkgroupInfo struct {
	Path     string
	Password string
}

type WorkgroupMembers

type WorkgroupMembers []string

type WorkgroupMembersPostParams

type WorkgroupMembersPostParams struct {
	Path    string
	IsAdd   bool
	Members WorkgroupMembers
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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