protocol

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package protocol contains declarations of the frames and JSON payload common to pollers, endpoints, etc

Index

Constants

View Source
const (
	PrepareActionStart    = "start"
	PrepareActionRestart  = "restart"
	PrepareActionContinue = "continue"

	PrepareDirectivePrepare = "prepare"
	PrepareDirectiveAbort   = "abort"

	PrepareResultStatusPrepared  = "prepared"
	PrepareResultStatusAborted   = "aborted"
	PrepareResultStatusFailed    = "failed"
	PrepareResultStatusIgnored   = "ignored"
	PrepareResultStatusCommitted = "committed"
)
View Source
const (
	// MethodEmpty indicates this message is a response
	MethodEmpty = ""

	// MethodHandshakeHello is SENT TO ---> endpoint server
	MethodHandshakeHello   = "handshake.hello"
	MethodCheckScheduleGet = "check_schedule.get"
	MethodPollerRegister   = "poller.register"
	// MethodHeartbeatPost is SENT TO ---> endpoint server
	MethodHeartbeatPost    = "heartbeat.post"
	MethodCheckMetricsPost = "check_metrics.post_multi"
	// MethodHostInfoGet is RECV FROM <--- endpoint server
	MethodHostInfoGet = "host_info.get"
	// MethodPollerPrepare is RECV FROM <--- endpoint server
	MethodPollerPrepare = "poller.prepare"
	// MethodPollerPrepareBlock is RECV FROM <--- endpoint server
	MethodPollerPrepareBlock = "poller.prepare.block"
	// MethodPollerPrepareEnd is RECV FROM <--- endpoint server
	MethodPollerPrepareEnd = "poller.prepare.end"
	// MethodPollerCommit is RECV FROM <--- endpoint server
	MethodPollerCommit = "poller.commit"
)
View Source
const (
	ProtocolVersion = "1"
)
View Source
const Version = "1"

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckScheduleGet

type CheckScheduleGet struct {
	FrameMsg
	Params map[string]uint64 `json:"params"`
}

func (CheckScheduleGet) Encode

func (r CheckScheduleGet) Encode() ([]byte, error)

type Error

type Error struct {
	Code    uint64 `json:"code"`
	Message string `json:"message"`
}

type Frame

type Frame interface {
	Encode() ([]byte, error)
	GetVersion() string
	SetVersion(string)
	GetId() uint64
	SetId(msgSeqId *uint64)
	SetRawId(uint64)
	GetTarget() string
	SetTarget(string)
	GetSource() string
	SetSource(string)
	GetMethod() string
	SetMethod(string)
	GetRawParams() json.RawMessage
	GetRawResult() json.RawMessage
	GetError() *Error
	SetFromFrameMsg(*FrameMsg)
}

func NewCheckScheduleGet

func NewCheckScheduleGet() Frame

func NewHandshakeRequest

func NewHandshakeRequest(cfg *config.Config) Frame

func NewPollerPrepareCommitResponse

func NewPollerPrepareCommitResponse(source *FrameMsg, result PollerCommitResult) Frame

func NewPollerPrepareResponse

func NewPollerPrepareResponse(source *FrameMsg, result PollerPrepareResult) Frame

type FrameMsg

type FrameMsg struct {
	FrameMsgCommon
	RawParams json.RawMessage `json:"params,omitempty"`
	RawResult json.RawMessage `json:"result,omitempty"`
}

FrameMsg implements Frame and conveys the raw params and result of a frame. This object is suitable for first-pass unmarshaling/decoding and for sending.

func NewFinishedFrame

func NewFinishedFrame() *FrameMsg

func (*FrameMsg) Encode

func (r *FrameMsg) Encode() ([]byte, error)

func (*FrameMsg) GetRawParams

func (f *FrameMsg) GetRawParams() json.RawMessage

func (*FrameMsg) GetRawResult

func (f *FrameMsg) GetRawResult() json.RawMessage

func (*FrameMsg) IsFinished

func (f *FrameMsg) IsFinished() bool

func (*FrameMsg) SetFromFrameMsg

func (f *FrameMsg) SetFromFrameMsg(source *FrameMsg)

type FrameMsgCommon

type FrameMsgCommon struct {
	Version string `json:"v"`
	Id      uint64 `json:"id"`
	Target  string `json:"target"`
	Source  string `json:"source"`
	Method  string `json:"method,omitempty"`
	Error   *Error `json:"error,omitempty"`
}

func (*FrameMsgCommon) Encode

func (r *FrameMsgCommon) Encode() ([]byte, error)

func (*FrameMsgCommon) GetError

func (f *FrameMsgCommon) GetError() *Error

func (*FrameMsgCommon) GetId

func (f *FrameMsgCommon) GetId() uint64

func (*FrameMsgCommon) GetMethod

func (f *FrameMsgCommon) GetMethod() string

func (*FrameMsgCommon) GetRawParams

func (f *FrameMsgCommon) GetRawParams() json.RawMessage

func (*FrameMsgCommon) GetRawResult

func (f *FrameMsgCommon) GetRawResult() json.RawMessage

func (*FrameMsgCommon) GetSource

func (f *FrameMsgCommon) GetSource() string

func (*FrameMsgCommon) GetTarget

func (f *FrameMsgCommon) GetTarget() string

func (*FrameMsgCommon) GetVersion

func (f *FrameMsgCommon) GetVersion() string

func (*FrameMsgCommon) SetFromFrameMsg

func (f *FrameMsgCommon) SetFromFrameMsg(source *FrameMsg)

func (*FrameMsgCommon) SetId

func (f *FrameMsgCommon) SetId(msgSeqId *uint64)

func (*FrameMsgCommon) SetMethod

func (f *FrameMsgCommon) SetMethod(method string)

func (*FrameMsgCommon) SetRawId

func (f *FrameMsgCommon) SetRawId(id uint64)

func (*FrameMsgCommon) SetResponseFrameMsg

func (f *FrameMsgCommon) SetResponseFrameMsg(source *FrameMsg)

func (*FrameMsgCommon) SetSource

func (f *FrameMsgCommon) SetSource(source string)

func (*FrameMsgCommon) SetTarget

func (f *FrameMsgCommon) SetTarget(target string)

func (*FrameMsgCommon) SetVersion

func (f *FrameMsgCommon) SetVersion(version string)

type HandshakeParameters

type HandshakeParameters struct {
	Token          string              `json:"token"`
	AgentId        string              `json:"agent_id"`
	AgentName      string              `json:"agent_name"`
	ProcessVersion string              `json:"process_version"`
	BundleVersion  string              `json:"bundle_version"`
	ZoneIds        []string            `json:"zone_ids"`
	Features       []map[string]string `json:"features"`
}

type HandshakeRequest

type HandshakeRequest struct {
	FrameMsg
	Params HandshakeParameters `json:"params"`
}

func (HandshakeRequest) Encode

func (r HandshakeRequest) Encode() ([]byte, error)

type HandshakeResponse

type HandshakeResponse struct {
	FrameMsg
	Result HandshakeResult `json:"result"`
}

func DecodeHandshakeResponse

func DecodeHandshakeResponse(frame *FrameMsg) *HandshakeResponse

type HandshakeResult

type HandshakeResult struct {
	// HeartbeatInterval indicates to the poller how often it should send a heartbeat.
	// Unit is millisecond.
	HeartbeatInterval uint64 `json:"heartbeat_interval"`
	EntityId          string `json:"entity_id"`
	Channel           string `json:"channel"`
}

type HeartbeatParameters

type HeartbeatParameters struct {
	Timestamp int64 `json:"timestamp"`
}

type HeartbeatRequest

type HeartbeatRequest struct {
	FrameMsg
	Params HeartbeatParameters `json:"params"`
}

func NewHeartbeatRequest

func NewHeartbeatRequest() *HeartbeatRequest

func (HeartbeatRequest) Encode

func (r HeartbeatRequest) Encode() ([]byte, error)

type HeartbeatResponse

type HeartbeatResponse struct {
	FrameMsg
	Result HeartbeatResult `json:"result"`
}

func DecodeHeartbeatResponse

func DecodeHeartbeatResponse(frame *FrameMsg) *HeartbeatResponse

type HeartbeatResult

type HeartbeatResult struct {
	Timestamp int64 `json:"timestamp"`
}

type HostInfoResponse

type HostInfoResponse struct {
	FrameMsgCommon

	Result interface{} `json:"result"`
}

func (*HostInfoResponse) Encode

func (r *HostInfoResponse) Encode() ([]byte, error)

type MetricTVU

type MetricTVU struct {
	Type  string `json:"t"`
	Value string `json:"v"`
	Unit  string `json:"u"`
}

type MetricWrap

type MetricWrap []map[string]*MetricTVU

type MetricWrapper

type MetricWrapper []MetricWrap

type MetricsPostRequest

type MetricsPostRequest struct {
	FrameMsg
	Params MetricsPostRequestParams `json:"params"`
}

func (MetricsPostRequest) Encode

func (r MetricsPostRequest) Encode() ([]byte, error)

type MetricsPostRequestParams

type MetricsPostRequestParams struct {
	EntityId       string       `json:"entity_id"`
	CheckId        string       `json:"check_id"`
	CheckType      string       `json:"check_type"`
	Metrics        []MetricWrap `json:"metrics"`
	MinCheckPeriod uint64       `json:"min_check_period"`
	State          string       `json:"state"`
	Status         string       `json:"status"`
	Timestamp      int64        `json:"timestamp"`
}

type PollerCommitParams

type PollerCommitParams struct {
	ZoneId  string `json:"zone_id"`
	Version int    `json:"version"`
}

PollerCommitParams is the params of a message with method=MethodPollerCommit

type PollerCommitRequest

type PollerCommitRequest struct {
	FrameMsg
	Params PollerCommitParams `json:"params"`
}

func DecodePollerCommitRequest

func DecodePollerCommitRequest(frame *FrameMsg) *PollerCommitRequest

type PollerCommitResponse

type PollerCommitResponse struct {
	FrameMsg
	Result PollerCommitResult `json:"result"`
}

type PollerCommitResult

type PollerCommitResult struct {
	ZoneId  string `json:"zone_id"`
	Version int    `json:"version"`
	// Status is one of PrepareResultStatus* constants
	Status  string `json:"status"`
	Details string `json:"details"`
}

type PollerPrepareBlockParams

type PollerPrepareBlockParams struct {
	ZoneId  string           `json:"zone_id"`
	Version int              `json:"version"`
	Block   []*check.CheckIn `json:"block"`
}

PollerPrepareBlockParams is the params of a message with method=MethodPollerPrepareBlock

type PollerPrepareBlockRequest

type PollerPrepareBlockRequest struct {
	FrameMsg
	Params PollerPrepareBlockParams `json:"params"`
}

func DecodePollerPrepareBlockRequest

func DecodePollerPrepareBlockRequest(frame *FrameMsg) *PollerPrepareBlockRequest

func (*PollerPrepareBlockRequest) GetPreparationVersion

func (req *PollerPrepareBlockRequest) GetPreparationVersion() int

func (*PollerPrepareBlockRequest) GetPreparationZoneId

func (req *PollerPrepareBlockRequest) GetPreparationZoneId() string

type PollerPrepareEndParams

type PollerPrepareEndParams struct {
	ZoneId  string `json:"zone_id"`
	Version int    `json:"version"`
	// Directive is one of PrepareDirective* constants
	Directive string `json:"directive"`
}

PollerPrepareBlockParams is the params of a message with method=MethodPollerPrepareEnd

type PollerPrepareEndRequest

type PollerPrepareEndRequest struct {
	FrameMsg
	Params PollerPrepareEndParams `json:"params"`
}

func DecodePollerPrepareEndRequest

func DecodePollerPrepareEndRequest(frame *FrameMsg) *PollerPrepareEndRequest

func (*PollerPrepareEndRequest) GetPreparationVersion

func (req *PollerPrepareEndRequest) GetPreparationVersion() int

func (*PollerPrepareEndRequest) GetPreparationZoneId

func (req *PollerPrepareEndRequest) GetPreparationZoneId() string

type PollerPrepareManifest

type PollerPrepareManifest struct {
	// Action is one of PrepareAction* constants
	Action    string `json:"action"`
	Id        string `json:"id"`
	CheckType string `json:"type"`
	EntityId  string `json:"entity_id"`
	ZoneId    string `json:"zone_id"`
}

type PollerPrepareRequest

type PollerPrepareRequest interface {
	GetPreparationZoneId() string
	GetPreparationVersion() int
}

PollerPrepareRequest abstracts common info across the "poller.prepare.*" methods

type PollerPrepareResponse

type PollerPrepareResponse struct {
	FrameMsg
	Result PollerPrepareResult `json:"result"`
}

type PollerPrepareResult

type PollerPrepareResult struct {
	ZoneId  string `json:"zone_id"`
	Version int    `json:"version"`
	// Status is one of PrepareResultStatus* constants
	Status  string `json:"status"`
	Details string `json:"details"`
}

type PollerPrepareStartParams

type PollerPrepareStartParams struct {
	ZoneId   string                  `json:"zone_id"`
	Version  int                     `json:"version"`
	Manifest []PollerPrepareManifest `json:"manifest"`
}

PollerPrepareStartParams is the params of a message with method=MethodPollerPrepare

type PollerPrepareStartRequest

type PollerPrepareStartRequest struct {
	FrameMsg
	Params PollerPrepareStartParams `json:"params"`
}

func DecodePollerPrepareStartRequest

func DecodePollerPrepareStartRequest(frame *FrameMsg) *PollerPrepareStartRequest

func (*PollerPrepareStartRequest) GetPreparationVersion

func (req *PollerPrepareStartRequest) GetPreparationVersion() int

func (*PollerPrepareStartRequest) GetPreparationZoneId

func (req *PollerPrepareStartRequest) GetPreparationZoneId() string

Directories

Path Synopsis
Package check provides the messaging structures specific to poller checks
Package check provides the messaging structures specific to poller checks
Package hostinfo provides the messaging structures specific to host info queries
Package hostinfo provides the messaging structures specific to host info queries
Package metric provides the messaging structures specific to metric reporting
Package metric provides the messaging structures specific to metric reporting

Jump to

Keyboard shortcuts

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