model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResNode   = "node"
	ResMember = "membership"
	ResTwin   = "twin"
	ResAuth   = "auth_info"
	ResDevice = "device"
)

constants for resource types

View Source
const (
	OpGet        = "get"
	OpResult     = "get_result"
	OpList       = "list"
	OpDetail     = "detail"
	OpDelta      = "delta"
	OpDoc        = "document"
	OpUpdate     = "updated"
	OpInsert     = "insert"
	OpDelete     = "deleted"
	OpConnect    = "connected"
	OpDisConnect = "disconnected"
	OpKeepalive  = "keepalive"
)

constants for resource operations

View Source
const (
	SrcCloudHub   = "cloudhub"
	SrcController = "controller"
	SrcManager    = "edgemgr"
)

constants for message source

View Source
const (
	GpResource = "resource"
)

constants for message group

Variables

This section is empty.

Functions

func EventToMessage

func EventToMessage(event *Event) model.Message

EventToMessage converts an event to a model message

func NewResource

func NewResource(resType, resID string, info *HubInfo) string

NewResource constructs a resource field using resource type and ID

Types

type Event

type Event struct {
	Group     string        `json:"msg_group"`
	Source    string        `json:"source"`
	UserGroup UserGroupInfo `json:"user_group"`
	ID        string        `json:"msg_id"`
	ParentID  string        `json:"parent_msg_id"`
	Timestamp int64         `json:"timestamp"`
	Content   interface{}   `json:"content"`
}

Event represents message communicated between cloud hub and edge hub

func MessageToEvent

func MessageToEvent(msg *model.Message) Event

MessageToEvent converts a model message to an event

func (*Event) GetContent

func (event *Event) GetContent() string

GetContent dumps the content to string

func (*Event) IsFromEdge

func (event *Event) IsFromEdge() bool

IsFromEdge judges if the event is sent from edge

func (*Event) IsNodeStopped

func (event *Event) IsNodeStopped() bool

IsNodeStopped indicates if the node is stopped or running

func (*Event) IsToEdge

func (event *Event) IsToEdge() bool

IsToEdge judges if the vent should be sent to edge

type HubInfo

type HubInfo struct {
	ProjectID string
	NodeID    string
}

HubInfo saves identifier information for edge hub

type UserGroupInfo

type UserGroupInfo struct {
	Resource  string `json:"resource"`
	Operation string `json:"operation"`
}

UserGroupInfo struct

Jump to

Keyboard shortcuts

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