model

package
v0.0.0-...-205ef5e Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

* ===========================================================================

  • 行为数据结构
  • Behavioral data structure

===========================================================================

* ===========================================================================

  • 双向链表队列
  • Double linked list queue

===========================================================================

Index

Constants

View Source
const (
	LogInfo int = iota
	LogDebug
	LogTrace
	LogWarn
	LogError
	LogCritical
)

* Log Type */

View Source
const ShardSize = 32

Variables

This section is empty.

Functions

This section is empty.

Types

type BehaviorActionS

type BehaviorActionS struct {
	Tag string
	// 任务
	Command string
	// 参数
	Params string
	// 回调
	Callback string
}

* 行为动作 */

type BehaviorForestS

type BehaviorForestS struct {
	// 行为树编号
	UUIDQ *QueueS /* UUID */
	// 行为树容器
	Trees SyncMapHub /* map[UUID]*model.BehaviorTreeS */
	// 错误容器
	ErrorQ *QueueS /* string */
}

type BehaviorTaskS

type BehaviorTaskS struct {
	Tag string
	// 任务开始时间
	Timestamp string
	Action    *QueueS
}

* 行为任务 */

type BehaviorTreeS

type BehaviorTreeS struct {
	Tag  string
	Task *QueueS
}

* 行为树 */

type CommanderPiece

type CommanderPiece struct {
	NeuronId string
	GMessage GMessageS
}

* CommanderQueue内容数据结构 */

type ConnQHub

type ConnQHub struct {
	//* 此Tag为QHub的名称 */
	Tag string
	//* [SocketClient] */
	ConnQ *QueueS
}

* UDP通信中心为链表形式 */

type Const

type Const struct {
	/* Application Running Environment
	0 -> dev
	1 -> test
	2 -> produce
	*/
	RunEnv        int
	Version       string
	NeuronId      string
	SystemSplit   string
	CommanderHost string
	CommanderLog  bool
	BehaviorTree  behaviorTreeS
	AutorunConfig autorunS
	ErrorCode     map[int]string
	Database      databaseS
	Redis         redisS
	File          fileS
	Proxy         proxyS
	HTTPRequest   requestS
	HTTPServer    serverS
	HTTPS         tlsServerS
	WSParam       wsParamS
	TCPParam      tcpParamS
	UDPParam      udpParamS
	UartParam     uartParamS
	Interval      intervalS
}

func (*Const) Ontology

func (*Const) Ontology() Const

* 构造本体 */

type ExpressI

type ExpressI interface {
	// 获取服务启动状态
	IsStarted() bool
	// 启动服务
	StartService()
	// 停止服务
	StopService()
}

* Saas服务接口 */

type GMessageS

type GMessageS struct {
	ID   string
	Head string
	Tag  string
	Cmds []interface{}
}

* 外部消息 */

type MessageS

type MessageS struct {
	Code    int
	Message string
	Data    interface{}
}

* 内部消息 */

type QueueS

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

func (*QueueS) Back

func (queue *QueueS) Back() *list.Element

* 获取链表尾 */

func (*QueueS) Contains

func (queue *QueueS) Contains(element interface{}) *list.Element

* 查询对象是否存在[存在则返回Element指针] */

func (*QueueS) Delete

func (queue *QueueS) Delete(e *list.Element) interface{}

* 删除链表 */

func (*QueueS) Front

func (queue *QueueS) Front() *list.Element

* 获取链表头 */

func (*QueueS) GetMaxLen

func (queue *QueueS) GetMaxLen() int

* 设置链表最大长度 */

func (*QueueS) IsEmpty

func (queue *QueueS) IsEmpty() bool

* 判断链表是否为空 */

func (*QueueS) Len

func (queue *QueueS) Len() int

* 获取链表长度 */

func (*QueueS) New

func (queue *QueueS) New(maxLen ...int) *QueueS

* 新建链栈链队列 */

func (*QueueS) Pop

func (queue *QueueS) Pop() interface{}

* 取队尾(出栈) */

func (*QueueS) PopPeek

func (queue *QueueS) PopPeek() interface{}

* 取队尾(不出栈) */

func (*QueueS) Push

func (queue *QueueS) Push(value interface{})

* 入队尾(入栈) */

func (*QueueS) Renew

func (queue *QueueS) Renew()

* 清空链表 */

func (*QueueS) SetMaxLen

func (queue *QueueS) SetMaxLen(maxLen int)

* 设置链表最大长度 */

func (*QueueS) Shift

func (queue *QueueS) Shift() interface{}

* 出队首(出队) */

func (*QueueS) ShiftPeek

func (queue *QueueS) ShiftPeek() interface{}

* 出队首(不出队) */

func (*QueueS) ToArray

func (queue *QueueS) ToArray() []*list.Element

* 链表转数组指针 */

func (*QueueS) ToArrayV

func (queue *QueueS) ToArrayV() []interface{}

* 链表转数组对象 */

func (*QueueS) UnShift

func (queue *QueueS) UnShift(value interface{})

* 入队首 */

type RequestParamS

type RequestParamS struct {
	PostData interface{}
	Host     string
	Path     string
	Header   map[string][]string
}

* Request参数 */

var postData = {
	'msg': 'Hello World!'
};
var params = {
	postData : postData,
	hostname: 'www.google.com',
	port: 80,
	path: '/upload',
	headers: {
		'Content-Type': 'application/x-www-form-urlencoded',
		'Content-Length': Buffer.byteLength(postData)
	}
}

type ResponseDataS

type ResponseDataS struct {
	URLProxy *url.URL
	Header   http.Header
	Body     []byte
}

* Response对象 */

type SQLDataS

type SQLDataS struct {
	Column []string
	// Rows.([]interface)[Column]
	Data []interface{}
}

* 数据库数据对象 */

type ServerS

type ServerS struct {
	Tag      string
	Alive    chan bool
	Services map[string]interface{}
}

* 神经元服务 */

type SocketClient

type SocketClient struct {
	//* 此Tag为配置文件中NeuronId */
	Tag  string
	Conn interface{} /* ws -> [*websocket.Conn] | tcp -> [net.Conn] | */
}

* Socket客户端结构 */

type SyncMapHub

type SyncMapHub struct {
	Tag string
	// contains filtered or unexported fields
}

* 线程安全的map容器 */

func (*SyncMapHub) AtomProcess

func (hub *SyncMapHub) AtomProcess(k string, cb func())

* 原子操作[防止指针引用过程中锁无效] */

func (*SyncMapHub) Convert2Map

func (hub *SyncMapHub) Convert2Map() map[string]interface{}

* 转化成map[string]interface{} */

func (*SyncMapHub) DeepCopyMap

func (hub *SyncMapHub) DeepCopyMap() <-chan syncMapTuple

* 利用Channel化数据深拷贝Map */

func (*SyncMapHub) Del

func (hub *SyncMapHub) Del(k string)

* 删除元素 */

func (*SyncMapHub) Get

func (hub *SyncMapHub) Get(k string) interface{}

* 获取元素 */

func (*SyncMapHub) GetShard

func (hub *SyncMapHub) GetShard(key string) *syncMapShard

* 根据Key获取分区编号 */

func (*SyncMapHub) Init

func (hub *SyncMapHub) Init(tags ...string)

* 初始化 */

func (*SyncMapHub) IsEmpty

func (hub *SyncMapHub) IsEmpty() bool

* 判断是否为空 */

func (*SyncMapHub) Iterator

func (hub *SyncMapHub) Iterator(cb func(n int, k string, v interface{}) bool)

* 迭代器 [return true -> 继续运行] [return false -> 停止运行] */

func (*SyncMapHub) Key2Slice

func (hub *SyncMapHub) Key2Slice(needSorts ...bool) []string

* 获取所有Key */

func (*SyncMapHub) Len

func (hub *SyncMapHub) Len() int

* 返回长度 */

func (*SyncMapHub) Pop

func (hub *SyncMapHub) Pop(k string) interface{}

* 获取元素并删除 */

func (*SyncMapHub) Set

func (hub *SyncMapHub) Set(k string, v interface{})

* 设置元素 */

func (*SyncMapHub) SetByMap

func (hub *SyncMapHub) SetByMap(data map[string]interface{})

* 通过map设置元素 */

func (*SyncMapHub) Val2Slice

func (hub *SyncMapHub) Val2Slice() []interface{}

* 获取所有Value */

type TimeS

type TimeS struct {
	YMD           string
	Week          time.Weekday
	Time          string
	Timestamp     string
	TimestampMill string
	TimestampNano string
	Datetime      time.Time
}

* 时间信息 */

type UDPPacket

type UDPPacket struct {
	Addr *net.UDPAddr
	Msg  []byte
}

* UDP通信消息数据结构 */

type WebsocketI

type WebsocketI interface {
	// 服务器容器
	WSHub() SyncMapHub
	// 消息解析模块
	GMessageHandler(interface{}, interface{})
}

* WS通信接口 */

Jump to

Keyboard shortcuts

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