dmcontext

package
v2.1.9 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: Apache-2.0 Imports: 16 Imported by: 14

Documentation

Index

Constants

View Source
const (
	DefaultDriverConf = "/etc/baetyl/driver.yml"
	DefaultPropsConf  = "/etc/baetyl/props.yml"
	KeyDevice         = "device"
	KeyStatus         = "status"
	OnlineStatus      = "online"
	OfflineStatus     = "offline"
)
View Source
const (
	DeviceTopicRe = "\\$baetyl/device/(.+)/(.+)"
)

Variables

View Source
var (
	ErrCallbackNotRegister     = errors.New("callback not registered yet")
	ErrInvalidCallback         = errors.New("invalid device callback")
	ErrInvalidMessage          = errors.New("invalid device message")
	ErrInvalidChannel          = errors.New("invalid channel")
	ErrResponseChannelNotExist = errors.New("response channel not exist")
)

Functions

func ParseTopic added in v2.1.8

func ParseTopic(topic string) (string, error)

func Run

func Run(handle func(Context) error)

Run service

Types

type Context

type Context interface {
	context.Context
	SystemConfigExt() *SystemConfig
	GetAllDevices() []DeviceInfo
	ReportDeviceProperties(info *DeviceInfo, props *DeviceProperties) error
	GetDeviceProperties(info *DeviceInfo) (*DeviceShadow, error)
	RegisterDeltaCallback(info *DeviceInfo, cb DeltaCallback)
	RegisterEventCallback(info *DeviceInfo, cb EventCallback)
	Online(info *DeviceInfo) error
	Offline(info *DeviceInfo) error
	GetDriverConfig() (string, error)
	GetDevicePropConfigs() (map[string]DevicePropConfigs, error)
	Start()
	io.Closer
}

func NewContext

func NewContext(confFile string) Context

type DeltaCallback

type DeltaCallback func(*DeviceInfo, *DeviceProperties) error

type DeviceEvent

type DeviceEvent struct {
	Name  string      `json:"name,omitempty"`
	Event interface{} `json:"event,omitempty"`
}

type DeviceInfo

type DeviceInfo struct {
	Name  string `yaml:"name,omitempty" json:"name,omitempty"`
	Topic `yaml:",inline" json:",inline"`
}

type DevicePropConfigs

type DevicePropConfigs struct {
	Name        string            `yaml:"name,omitempty" json:"name,omitempty"`
	PropConfigs map[string]string `yaml:"propConfigs,omitempty" json:"propConfigs,omitempty"`
}

type DeviceProperties

type DeviceProperties struct {
	Name  string                 `json:"name,omitempty"`
	Props map[string]interface{} `json:"props,omitempty"`
}

type DeviceShadow

type DeviceShadow struct {
	Name   string    `json:"name,omitempty"`
	Report v1.Report `json:"report,omitempty"`
	Desire v1.Desire `json:"desire,omitempty"`
}

type DmCtx

type DmCtx struct {
	context.Context
	// contains filtered or unexported fields
}

func (*DmCtx) Close

func (c *DmCtx) Close() error

func (*DmCtx) GetAllDevices

func (c *DmCtx) GetAllDevices() []DeviceInfo

func (*DmCtx) GetDevicePropConfigs

func (c *DmCtx) GetDevicePropConfigs() (map[string]DevicePropConfigs, error)

func (*DmCtx) GetDeviceProperties

func (c *DmCtx) GetDeviceProperties(info *DeviceInfo) (*DeviceShadow, error)

func (*DmCtx) GetDriverConfig

func (c *DmCtx) GetDriverConfig() (string, error)

func (*DmCtx) Offline

func (c *DmCtx) Offline(info *DeviceInfo) error

func (*DmCtx) Online

func (c *DmCtx) Online(info *DeviceInfo) error

func (*DmCtx) RegisterDeltaCallback

func (c *DmCtx) RegisterDeltaCallback(info *DeviceInfo, cb DeltaCallback)

func (*DmCtx) RegisterEventCallback

func (c *DmCtx) RegisterEventCallback(info *DeviceInfo, cb EventCallback)

func (*DmCtx) ReportDeviceProperties

func (c *DmCtx) ReportDeviceProperties(info *DeviceInfo, props *DeviceProperties) error

func (*DmCtx) Start

func (c *DmCtx) Start()

func (*DmCtx) SystemConfigExt

func (c *DmCtx) SystemConfigExt() *SystemConfig

type EventCallback

type EventCallback func(*DeviceInfo, *DeviceEvent) error

type SystemConfig

type SystemConfig struct {
	context.SystemConfig `yaml:",inline" json:",inline"`
	Devices              []DeviceInfo `yaml:"devices,omitempty" json:"devices,omitempty"`
}

type Topic

type Topic struct {
	Delta       mqtt2.QOSTopic `yaml:"delta,omitempty" json:"delta,omitempty"`
	Report      mqtt2.QOSTopic `yaml:"report,omitempty" json:"report,omitempty"`
	Event       mqtt2.QOSTopic `yaml:"event,omitempty" json:"event,omitempty"`
	Get         mqtt2.QOSTopic `yaml:"get,omitempty" json:"get,omitempty"`
	GetResponse mqtt2.QOSTopic `yaml:"getResponse,omitempty" json:"getResponse,omitempty"`
}

Jump to

Keyboard shortcuts

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