events

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NatsSubWithType added in v0.5.1

func NatsSubWithType[msgType any](handle func(ctx context.Context, msgIn msgType, natsMsg *nats.Msg) error) func(msg *nats.Msg)

func NatsSubscription

func NatsSubscription(handle HandleFunc) func(msg *nats.Msg)

func NewEventMsg

func NewEventMsg(ctx context.Context, data []byte) []byte

Types

type ChangeInfo added in v0.5.1

type ChangeInfo struct {
	ID int64
}

type DeviceCore added in v0.3.0

type DeviceCore struct {
	ProductID  string `json:"productID"`  //产品id
	DeviceName string `json:"deviceName"` //设备名称
}

type DeviceUpdateInfo added in v0.5.1

type DeviceUpdateInfo struct {
	ProductID  string
	DeviceName string
	Data       any
}

type EventHandle

type EventHandle interface {
	GetCtx() context.Context
	GetTs() time.Time
	GetData() []byte
}

func GetEventMsg

func GetEventMsg(data []byte) EventHandle

type GatewayUpdateInfo added in v0.3.0

type GatewayUpdateInfo struct {
	GatewayProductID  string
	GatewayDeviceName string
	Status            int32         //拓扑关系变化状态。* 2:解绑* 1:绑定
	Devices           []*DeviceCore //子设备列表
}

type HandleFunc

type HandleFunc func(ctx context.Context, msg []byte, natsMsg *nats.Msg) error

type MsgHead

type MsgHead struct {
	Trace     []byte `json:"trace"`     //追踪tid
	Timestamp int64  `json:"timestamp"` //发送时毫秒级时间戳
	Data      []byte `json:"data"`      //传送的内容
}

MsgHead 消息队列的头 todo 后续考虑用proto重构这个头

func (*MsgHead) GetCtx

func (m *MsgHead) GetCtx() context.Context

func (*MsgHead) GetData

func (m *MsgHead) GetData() []byte

func (*MsgHead) GetTs

func (m *MsgHead) GetTs() time.Time

type MySpanContextConfig

type MySpanContextConfig struct {
	TraceID string
	SpanID  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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