protocol

package
v0.0.0-...-bd520fb Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InsertOperation        = "insert"
	DeleteOperation        = "delete"
	QueryOperation         = "query"
	UpdateOperation        = "update"
	ResponseOperation      = "response"
	ResponseErrorOperation = "error"

	ResourceTypePod        = "pod"
	ResourceTypeConfigmap  = "configmap"
	ResourceTypeSecret     = "secret"
	ResourceTypeNode       = "node"
	ResourceTypePodlist    = "podlist"
	ResourceTypePodStatus  = "podstatus"
	ResourceTypeNodeStatus = "nodestatus"
)

Constants for database operations and resource type settings

Variables

This section is empty.

Functions

This section is empty.

Types

type ApulisHeader

type ApulisHeader struct {
	ClusterId int64 `json:"clusterId"`
	GroupId   int64 `json:"groupId"`
	UserId    int64 `json:"userId"`
}

ApulisHeader struct

type Message

type Message struct {
	Header  MessageHeader `json:"header" binding:"required,dive"`
	Router  MessageRoute  `json:"route" binding:"required,dive"`
	Content interface{}   `json:"content" binding:"required"`
}

Message struct

func NewErrorMessage

func NewErrorMessage(message *Message, errContent string) *Message

NewErrorMessage returns a new error message by a message received

func NewMessage

func NewMessage(parentID string) *Message

NewMessage returns a new basic message: model.NewMessage().BuildRouter().FillBody()

func NewRawMessage

func NewRawMessage() *Message

NewRawMessage returns a new raw message: model.NewRawMessage().BuildHeader().BuildRouter().FillBody()

func (*Message) BuildHeader

func (msg *Message) BuildHeader(ID, parentID string, timestamp int64) *Message

BuildHeader builds message header. You can also use for updating message header

func (*Message) BuildRouter

func (msg *Message) BuildRouter(source, group, res, opr string) *Message

BuildRouter sets route and resource operation in message

func (*Message) Clone

func (msg *Message) Clone(message *Message) *Message

Clone a message only update message id

func (*Message) FillBody

func (msg *Message) FillBody(content interface{}) *Message

FillBody fills message content that you want to send

func (*Message) GetContent

func (msg *Message) GetContent() interface{}

GetContent returns message content

func (*Message) GetGroup

func (msg *Message) GetGroup() string

GetGroup returns message route group

func (*Message) GetID

func (msg *Message) GetID() string

GetID returns message ID

func (*Message) GetOperation

func (msg *Message) GetOperation() string

GetOperation returns message route operation string

func (*Message) GetParentID

func (msg *Message) GetParentID() string

GetParentID returns message parent id

func (*Message) GetResource

func (msg *Message) GetResource() string

GetResource returns message route resource

func (*Message) GetResourceVersion

func (msg *Message) GetResourceVersion() string

GetResourceVersion returns message resource version

func (*Message) GetSource

func (msg *Message) GetSource() string

GetSource returns message route source string

func (*Message) GetTimestamp

func (msg *Message) GetTimestamp() int64

GetTimestamp returns message timestamp

func (*Message) IsSync

func (msg *Message) IsSync() bool

IsSync : msg.Header.Sync will be set in sendsync

func (*Message) NewRespByMessage

func (msg *Message) NewRespByMessage(message *Message, content interface{}) *Message

NewRespByMessage returns a new response message by a message received

func (*Message) SetResourceOperation

func (msg *Message) SetResourceOperation(res, opr string) *Message

SetResourceOperation sets router resource and operation in message

func (*Message) SetResourceVersion

func (msg *Message) SetResourceVersion(resourceVersion string) *Message

SetResourceVersion sets resource version in message header

func (*Message) SetRoute

func (msg *Message) SetRoute(source, group string) *Message

SetRoute sets router source and group in message

func (*Message) UpdateID

func (msg *Message) UpdateID() *Message

UpdateID returns message object updating its ID

type MessageHeader

type MessageHeader struct {
	// the message uuid
	ID string `json:"msg_id" binding:"required"`
	// the response message parentid must be same with message received
	// please use NewRespByMessage to new response message
	ParentID string `json:"parent_msg_id,omitempty"`
	// the time of creating
	Timestamp int64 `json:"timestamp" binding:"required"`
	// specific resource version for the message, if any.
	// it's currently backed by resource version of the k8s object saved in the Content field.
	// kubeedge leverages the concept of message resource version to achieve reliable transmission.
	ResourceVersion string `json:"resourceversion,omitempty"`
	// the flag will be set in sendsync
	Sync bool `json:"sync,omitempty"`
}

MessageHeader defines message header details

type MessageRoute

type MessageRoute struct {
	// where the message come from
	Source string `json:"source" binding:"required"`
	// where the message will broadcasted to
	Group string `json:"group,omitempty"`

	// what's the operation on resource
	Operation string `json:"operation" binding:"required"`
	// what's the resource want to operate
	Resource string `json:"resource,omitempty"`
}

MessageRoute contains structure of message

Jump to

Keyboard shortcuts

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