watch

package
v0.0.0-...-cb472e6 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoEventCursor string

this cursor means there is no event occurs. we send this cursor to our the watcher and if we received a NoEventCursor, then we need to fetch event from the head cursor

Functions

func GetEventCursor

func GetEventCursor(coll string, e *types.Event) (string, error)

Types

type ChainNode

type ChainNode struct {
	// event's cluster time
	ClusterTime types.TimeStamp `json:"cluster_time"`
	// event's document object id, as is the value of "_id" in a document.
	Oid string `json:"oid"`
	// event's type
	EventType EventType `json:"type"`
	// event's resume token, if token is "", then it's a head, and no tail
	Token string `json:"token"`
	// the current node's cursor
	Cursor string `json:"cursor"`
	// generated by cmdb, and is 1:1 with mongodb's resume token
	// the next cursor's value
	NextCursor string `json:"next_cursor"`
}

type Cursor

type Cursor struct {
	Type        CursorType
	ClusterTime types.TimeStamp
	// a random hex string to avoid the caller to generated a self-defined cursor.
	Oid string
}

Cursor is a self-defined token which is corresponding to the mongodb's resume token. cursor has a unique and 1:1 relationship with mongodb's resume token.

func (*Cursor) Decode

func (c *Cursor) Decode(cur string) error

func (Cursor) Encode

func (c Cursor) Encode() (string, error)

type CursorType

type CursorType string
const (
	NoEvent                 CursorType = "no_event"
	UnknownType             CursorType = "unknown"
	Host                    CursorType = "host"
	ModuleHostRelation      CursorType = "host_relation"
	Biz                     CursorType = "biz"
	Set                     CursorType = "set"
	Module                  CursorType = "module"
	SetTemplate             CursorType = "set_template"
	ObjectBase              CursorType = "object_instance"
	Process                 CursorType = "process"
	ProcessInstanceRelation CursorType = "process_instance_relation"
)

func ListCursorTypes

func ListCursorTypes() []CursorType

ListCursorTypes returns all support CursorTypes.

func ListEventCallbackCursorTypes

func ListEventCallbackCursorTypes() []CursorType

ListEventCallbackCursorTypes returns all support CursorTypes for event callback.

func (*CursorType) ParseInt

func (ct *CursorType) ParseInt(typ int)

func (CursorType) ToInt

func (ct CursorType) ToInt() int

type DetailInterface

type DetailInterface interface {
	Name() string
}

type EventType

type EventType string
const (
	Create  EventType = "create"
	Update  EventType = "update"
	Delete  EventType = "delete"
	Unknown EventType = "unknown"
)

func ConvertOperateType

func ConvertOperateType(typ types.OperType) EventType

func (EventType) Validate

func (e EventType) Validate() error

type JsonString

type JsonString string

func (JsonString) MarshalJSON

func (j JsonString) MarshalJSON() ([]byte, error)

func (JsonString) Name

func (j JsonString) Name() string

type WatchEventDetail

type WatchEventDetail struct {
	Cursor    string     `json:"bk_cursor"`
	Resource  CursorType `json:"bk_resource"`
	EventType EventType  `json:"bk_event_type"`
	// Default instance is JsonString type
	Detail DetailInterface `json:"bk_detail"`
}

type WatchEventOptions

type WatchEventOptions struct {
	// event types you want to care, empty means all.
	EventTypes []EventType `json:"bk_event_types"`
	// the fields you only care, if nil, means all.
	Fields []string `json:"bk_fields"`
	// unix seconds time to where you want to watch from.
	// it's like Cursor, but StartFrom and Cursor can not use at the same time.
	StartFrom int64 `json:"bk_start_from"`
	// the cursor you hold previous, means you want to watch event form here.
	Cursor string `json:"bk_cursor"`
	// the resource kind you want to watch
	Resource CursorType `json:"bk_resource"`
}

func (*WatchEventOptions) Validate

func (w *WatchEventOptions) Validate() error

type WatchResp

type WatchResp struct {
	// watched events or not
	Watched bool                `json:"bk_watched"`
	Events  []*WatchEventDetail `json:"bk_events"`
}

Jump to

Keyboard shortcuts

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