custom

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: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CustomType = "custom" //自定义协议topic type定义
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConvertFunc

type ConvertFunc func(data []byte) ([]byte, error)

type ConvertType

type ConvertType int
const (
	ConvertTypeUp        ConvertType = iota //自定义协议转iThings协议
	ConvertTypeDown                         //iThings协议转自定义协议
	ConvertTypeTransform                    //自定义topic协议转换
)

type Info

type Info struct {
	ProductID       string
	TransformScript *string //可能为空
	ScriptLang      int64
	CustomTopic     []string
}

func (*Info) InitScript

func (i *Info) InitScript() *Vm

type Repo

type Repo interface {
	// GetProtoFunc 自定义协议转iTHings协议
	GetProtoFunc(ctx context.Context, productID string, dir ConvertType,
		handle string,
		Type string) (ConvertFunc, error)
	// GetTransFormFunc 自定义topic转换函数
	GetTransFormFunc(ctx context.Context, productID string, direction devices.Direction) (TransFormFunc, error)
	// ClearCache 清除缓存
	ClearCache(ctx context.Context, productID string) error
}

type TransFormFunc

type TransFormFunc func(topic string, data []byte) (*TransformRet, error)

type TransformRet

type TransformRet struct {
	Topic   string `json:"topic"`
	PayLoad []byte `json:"payLoad"`
}

type Vm

type Vm struct {
	sync.Pool
}

func (*Vm) DataDown

func (v *Vm) DataDown(ctx context.Context,
	handle string,
	Type string) ConvertFunc

下行数据

func (*Vm) DataUp

func (v *Vm) DataUp(ctx context.Context,
	handle string,
	Type string) ConvertFunc

上行数据

func (*Vm) TransformPayload

func (v *Vm) TransformPayload(ctx context.Context, dir devices.Direction) TransFormFunc

Jump to

Keyboard shortcuts

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