model

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: Apache-2.0 Imports: 6 Imported by: 130

Documentation

Index

Constants

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

	ResourceTypePod                 = "pod"
	ResourceTypeConfigmap           = "configmap"
	ResourceTypeServiceAccountToken = "serviceaccounttoken"
	ResourceTypeSecret              = "secret"
	ResourceTypeNode                = "node"
	ResourceTypePodlist             = "podlist"
	ResourceTypePodStatus           = "podstatus"
	ResourceTypePodPatch            = "podpatch"
	ResourceTypeNodeStatus          = "nodestatus"
	ResourceTypeNodePatch           = "nodepatch"
	ResourceTypeRule                = "rule"
	ResourceTypeRuleEndpoint        = "ruleendpoint"
	ResourceTypeRuleStatus          = "rulestatus"
	ResourceTypeLease               = "lease"
)

Constants for database operations and resource type settings

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

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

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) GetContentData

func (msg *Message) GetContentData() ([]byte, error)

GetContentData returns message content data

func (*Message) GetDestination added in v1.9.3

func (msg *Message) GetDestination() string

GetDestination get destination

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) GetType added in v1.9.3

func (msg *Message) GetType() string

GetType get message context type

func (*Message) IsEmpty added in v1.9.3

func (msg *Message) IsEmpty() bool

IsEmpty is empty

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) SetDestination added in v1.9.3

func (msg *Message) SetDestination(dest string) *Message

SetDestination set destination

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) SetType added in v1.9.3

func (msg *Message) SetType(msgType string) *Message

SetType set message context type

func (*Message) String added in v1.9.3

func (msg *Message) String() string

String the content that you want to send

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"`
	// 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"`
	// 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"`
	// message type indicates the context type that delivers the message, such as channel, unixsocket, etc.
	// if the value is empty, the channel context type will be used.
	MessageType string `json:"type,omitempty"`
}

MessageHeader defines message header details

type MessageRoute

type MessageRoute struct {
	// where the message come from
	Source string `json:"source,omitempty"`
	// where the message will send to
	Destination string `json:"destination,omitempty"`
	// where the message will broadcast to
	Group string `json:"group,omitempty"`

	// what's the operation on resource
	Operation string `json:"operation,omitempty"`
	// 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