dslink

package module
v0.0.0-...-46a6a0a Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

README

Future home of IOT-DSA DSLink in Go

Currently the code here does not work. Do not try to use this sdk to create a DSLink it will not work!

Documentation

Index

Constants

View Source
const (
	ResultValues = "values"
	ResultTable  = "table"
	ResultStream = "stream"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Name    string
	Type    ValueType
	Default interface{}
}

type Invokable

type Invokable interface {
	Invoke(*Request)
}

type InvokeFn

type InvokeFn func(map[string]interface{}, chan<- []interface{})

type Lister

type Lister interface {
	List(*Request) *Response
	Close(*Request)
}

type Mapper

type Mapper interface {
	ToMap() map[string]interface{}
}

type Message

type Message struct {
	Msg  int32       `json:"msg" msgpack:"msg"`
	Ack  int32       `json:"ack,omitempty" msgpack:"ack,omitempty"`
	Reqs []*Request  `json:"requests,omitempty" msgpack:"requests,omitempty"`
	Resp []*Response `json:"responses,omitempty" msgpack:"responses,omitempty"`
	Salt string      `json:"salt,omitempty" msgpack:"salt,omitempty"`
}

func (*Message) String

func (m *Message) String() string

type MethodType

type MethodType string
const (
	MethodList   MethodType = "list"
	MethodSub    MethodType = "subscribe"
	MethodUnsub  MethodType = "unsubscribe"
	MethodClose  MethodType = "close"
	MethodSet    MethodType = "set"
	MethodRemove MethodType = "remove"
	MethodInvoke MethodType = "invoke"
)

type MsgErr

type MsgErr struct {
	Type   string `json:"type" msgpack:"type"`
	Msg    string `json:"msg" msgpack:"msg"`
	Phase  string `json:"phase" msgpack:"phase"`
	Path   string `json:"path" msgpack:"path"`
	Detail string `json:"detail" msgpack:"detail"`
}
var (
	ErrPermissionDenied *MsgErr = &MsgErr{Type: "permissionDenied"}
	ErrInvalidMethod    *MsgErr = &MsgErr{Type: "invalidMethod"}
	ErrNotImplemented   *MsgErr = &MsgErr{Type: "notImplemented"}
	ErrInvalidPath      *MsgErr = &MsgErr{Type: "invalidPath"}
	ErrInvalidPaths     *MsgErr = &MsgErr{Type: "invalidPaths"}
	ErrInvalidValue     *MsgErr = &MsgErr{Type: "invalidValue"}
	ErrInvalidParam     *MsgErr = &MsgErr{Type: "invalidParameter"}
	ErrDisconnected     *MsgErr = &MsgErr{Type: "disconnected", Phase: "response"}
	ErrFailed           *MsgErr = &MsgErr{Type: "failed"}
)

func (*MsgErr) String

func (e *MsgErr) String() string

type Node

type Node interface {
	Name() string
	Attributes() map[string]interface{}
	GetAttribute(string) (interface{}, bool)
	SetAttribute(string, interface{})
	Configs() map[NodeConfig]interface{}
	GetConfig(NodeConfig) (interface{}, bool)
	SetConfig(NodeConfig, interface{})
}

type NodeConfig

type NodeConfig string
const (
	ConfigBase         NodeConfig = "$base"
	ConfigIs           NodeConfig = "$is"
	ConfigInterface    NodeConfig = "$interface"
	ConfigDisconnected NodeConfig = "$disconnectedTs"
	ConfigPermission   NodeConfig = "$permission"
	ConfigPermissions  NodeConfig = "$$permissions"
	ConfigName         NodeConfig = "$name"
	ConfigType         NodeConfig = "$type"
	ConfigWritable     NodeConfig = "$writable"
	ConfigSetings      NodeConfig = "$settings"
	ConfigParams       NodeConfig = "$params"
	ConfigColumns      NodeConfig = "$columns"
	ConfigResult       NodeConfig = "$result"
	ConfigStreamMeta   NodeConfig = "$streamMeta"
	ConfigInvokable    NodeConfig = "$invokable"
)

type OnSetValue

type OnSetValue func(Node, interface{}) bool

type ParamVal

type ParamVal string
const (
	// ParamName is the name of the parameter. Used in Invoke actions.
	ParamName ParamVal = "name"
	// ParamType is the type of the parameter. Used in Invoke actions.
	ParamType ParamVal = "type"
	// ParamDef is the default value of the parameter. Used in Invoke actions.
	ParamDef ParamVal = "default"
	// ParamEditor is the editor for the type. Used in Invoke actions.
	ParamEditor ParamVal = "editor"
	// ParamHolder is the placeholder for the value. Used in Invoke actions.
	ParamHolder ParamVal = "placeholder"
	// ParamDesc is the parameter description. Used in Invoke actions.
	ParamDesc ParamVal = "description"
)

type Params

type Params map[ParamVal]interface{}

func (Params) Get

func (p Params) Get(val ParamVal) interface{}

func (Params) Set

func (p Params) Set(key ParamVal, val interface{})

type PermType

type PermType string

PermType is the Permission type.

const (
	// PermNone is permission none.
	PermNone PermType = "none"
	// PermRead is permission Read only
	PermRead PermType = "read"
	// PermWrite is permission write
	PermWrite PermType = "write"
	// PermConfig is permission config
	PermConfig PermType = "config"
	// PermNever is permission never
	PermNever PermType = "never"
)

func (PermType) Level

func (p PermType) Level() int

type Request

type Request struct {
	Rid    int32                  `json:"rid" msgpack:"rid"`
	Method MethodType             `json:"method" msgpack:"method"`
	Path   string                 `json:"path,omitempty" msgpack:"path,omitempty"`
	Paths  []*SubPath             `json:"paths,omitempty" msgpack:"paths,omitempty"`
	Sids   []int32                `json:"sids,omitempty" msgpack:"sids,omitempty"`
	Params map[string]interface{} `json:"params,omitempty" msgpack:"params,omitempty"`
	Permit string                 `json:"permit,omitempty" msgpack:"permit,omitempty"`
	Value  interface{}            `json:"value,omitempty" msgpack:"value,omitempty"`
}

func NewReq

func NewReq(rid int32, method MethodType) *Request

func (*Request) String

func (r *Request) String() string

type Requester

type Requester interface {
	HandleResponse(*Response)
	SendRequest(*Request, chan *Response)
}

type Responder

type Responder interface {
	HandleRequest(req *Request) *Response
	SendResponse(resp *Response)
}

type Response

type Response struct {
	Rid     int32                    `json:"rid" msgpack:"rid"`
	Stream  StreamState              `json:"stream" msgpack:"stream"`
	Updates []interface{}            `json:"updates" msgpack:"updates"`
	Columns []map[string]interface{} `json:"columns,omitempty" msgpack:"columns,omitempty"`
	Error   *MsgErr                  `json:"error,omitempty" msgpack:"error,omitempty"`
}

func NewResp

func NewResp(rid int32) *Response

func (*Response) AddUpdate

func (r *Response) AddUpdate(name interface{}, value interface{})

func (*Response) String

func (r *Response) String() string

type Settable

type Settable interface {
	Set(*Request) *MsgErr
	EnableSet(PermType, OnSetValue)
}

type StreamState

type StreamState string
const (
	StreamInit   StreamState = "initialize"
	StreamOpen   StreamState = "open"
	StreamClosed StreamState = "closed"
)

type SubPath

type SubPath struct {
	Path string `json:"path" msgpack:"path"`
	Sid  int32  `json:"sid" msgpack:"sid"`
	Qos  uint8  `json:"qos,omitempty" msgpack:"qos,omitempty"`
}

func (*SubPath) String

func (sp *SubPath) String() string

type ValueType

type ValueType string

ValueType represents the type of value stored by the Node

const (
	// ValueBool indicates this value type is a boolean
	ValueBool ValueType = "bool"
	// ValueNum indicates this value type is a number (integer or double)
	ValueNum ValueType = "num"
	// ValueString indicates this value type is a String
	ValueString ValueType = "string"
	// ValueDynamic indicates this value type is of an undetermined type
	ValueDynamic ValueType = "dynamic"
	// ValueDynamic indicates this value type is a Map
	ValueMap ValueType = "map"
	// ValueDynamic indicates this value type is an Array
	ValueArray ValueType = "array"
)

func GenerateEnumValue

func GenerateEnumValue(options ...string) ValueType

type ValueUpdate

type ValueUpdate struct {
	// contains filtered or unexported fields
}

func NewValueUpdate

func NewValueUpdate(value interface{}) *ValueUpdate

func (*ValueUpdate) GetTs

func (v *ValueUpdate) GetTs() time.Time

func (*ValueUpdate) Value

func (v *ValueUpdate) Value() interface{}

type Valued

type Valued interface {
	GetType() ValueType
	SetType(ValueType)
	UpdateValue(interface{})
	Value() interface{}
	Subscribe(int32)
	Unsubscribe(int32)
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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