api

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAuthHeader

func GetAuthHeader(token string) req.Headers

GetAuthHeader return API authentication header

Types

type ClientInfo

type ClientInfo struct {
	CID            string      `json:"cid"`
	Role           string      `json:"role"`
	Version        string      `json:"version"`
	Hostname       string      `json:"hostname"`
	IP             string      `json:"ip"`
	ConnectionDate int64       `json:"connection_date"`
	State          ClientState `json:"state"`
}

type ClientState

type ClientState uint8
const (
	STATE_UNKNOWN ClientState = iota
	STATE_ONLINE
	STATE_POSSIBLE_DOWN
	STATE_DOWN
	STATE_SYNCING
	STATE_DEAD
)

func (ClientState) String

func (s ClientState) String() string

String returns string representation of client status

type CommandQueue

type CommandQueue struct {
	Items   []*CommandQueueItem `json:"items"`    // Items with actions
	ModTime int64               `json:"mod_time"` // Time of latest action
}

CommandQueue is command queue

type CommandQueueItem

type CommandQueueItem struct {
	Command      MasterCommand `json:"command"`
	InstanceID   int           `json:"instance_id"`
	InstanceUUID string        `json:"instance_uuid"`
	Timestamp    int64         `json:"timestamp"`
}

type CoreCompatibility

type CoreCompatibility uint8
const (
	CORE_COMPAT_OK CoreCompatibility = iota
	CORE_COMPAT_PARTIAL
	CORE_COMPAT_ERROR
)

type DefaultRequest

type DefaultRequest struct {
	CID string `json:"cid"`
}

type DefaultResponse

type DefaultResponse struct {
	Status ResponseStatus `json:"status"`
}

type FetchResponse

type FetchResponse struct {
	Instances []*CORE.InstanceInfo `json:"instances"`
	Status    ResponseStatus       `json:"status"`
}

type HelloRequest

type HelloRequest struct {
	Version  string `json:"version"`
	Hostname string `json:"hostname"`
	Role     string `json:"role"`
}

type HelloResponse

type HelloResponse struct {
	Status        ResponseStatus      `json:"status"`
	Version       string              `json:"version"`
	CID           string              `json:"cid"`
	Auth          *CORE.SuperuserAuth `json:"auth"`
	SentinelWorks bool                `json:"sentinel_works"`
}

type InfoRequest

type InfoRequest struct {
	CID  string `json:"cid"`
	ID   int    `json:"id"`
	UUID string `json:"UUID"`
}

type InfoResponse

type InfoResponse struct {
	Status ResponseStatus     `json:"status"`
	Info   *CORE.InstanceInfo `json:"info"`
}

type MasterCommand

type MasterCommand string
const (
	COMMAND_CREATE         MasterCommand = "create"
	COMMAND_DESTROY        MasterCommand = "destroy"
	COMMAND_EDIT           MasterCommand = "edit"
	COMMAND_START          MasterCommand = "start"
	COMMAND_STOP           MasterCommand = "stop"
	COMMAND_RESTART        MasterCommand = "restart"
	COMMAND_START_ALL      MasterCommand = "start-all"
	COMMAND_STOP_ALL       MasterCommand = "stop-all"
	COMMAND_RESTART_ALL    MasterCommand = "restart-all"
	COMMAND_SENTINEL_START MasterCommand = "sentinel-start"
	COMMAND_SENTINEL_STOP  MasterCommand = "sentinel-stop"
)

type MasterCommandInfo

type MasterCommandInfo struct {
	Command MasterCommand `json:"command"`
	ID      int           `json:"id"`
	UUID    string        `json:"uuid"`
}

type MasterInfo

type MasterInfo struct {
	Version  string `json:"version"`
	Hostname string `json:"hostname"`
	IP       string `json:"ip"`
}

type Method

type Method string
const (
	METHOD_HELLO       Method = "hello"
	METHOD_PUSH        Method = "push"
	METHOD_PULL        Method = "pull"
	METHOD_FETCH       Method = "fetch"
	METHOD_INFO        Method = "info"
	METHOD_REPLICATION Method = "replication"
	METHOD_STATS       Method = "stats"
)

type PullResponse

type PullResponse struct {
	Commands []*CommandQueueItem `json:"commands"`
	Status   ResponseStatus      `json:"status"`
}

type PushRequest

type PushRequest struct {
	Command MasterCommand `json:"command"`
	ID      int           `json:"id"`
	UUID    string        `json:"uuid"`
}

type ReplicationInfo

type ReplicationInfo struct {
	Master       *MasterInfo   `json:"master"`
	Clients      []*ClientInfo `json:"clients"`
	SuppliantCID string        `json:"suppliant_cid,omitempty"`
}

type ReplicationResponse

type ReplicationResponse struct {
	Status ResponseStatus   `json:"status"`
	Info   *ReplicationInfo `json:"info"`
}

type ResponseStatus

type ResponseStatus struct {
	Desc string     `json:"desc"`
	Code StatusCode `json:"code"`
}

type StatsInfo

type StatsInfo struct {
	Minions    int     `json:"minions"`
	Sentinels  int     `json:"sentinels"`
	MaxSeenLag float64 `json:"max_seen_lag"`
	MaxSyncLag float64 `json:"max_sync_lag"`
}

type StatsResponse

type StatsResponse struct {
	Status ResponseStatus `json:"status"`
	Stats  *StatsInfo     `json:"stats"`
}

type StatusCode

type StatusCode uint8
const (
	STATUS_OK                        StatusCode = 0
	STATUS_WRONG_REQUEST             StatusCode = 1
	STATUS_WRONG_AUTH_TOKEN          StatusCode = 2
	STATUS_UNKNOWN_CLIENT            StatusCode = 3
	STATUS_WRONG_METHOD              StatusCode = 4
	STATUS_WRONG_ARGS                StatusCode = 5
	STATUS_INCORRECT_REQUEST         StatusCode = 6
	STATUS_UNKNOWN_INSTANCE          StatusCode = 7
	STATUS_INCOMPATIBLE_CORE_VERSION StatusCode = 8
	STATUS_UNKNOWN_ERROR             StatusCode = 99
)

Jump to

Keyboard shortcuts

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