Discover Packages
github.com/lindorof/gilix
package
module
Version:
v0.1.21
Opens a new window with list of versions in this module.
Published: Oct 12, 2023
License: MIT
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 2
Opens a new window with list of known importers.
README
README
¶
gilix
介绍
基于 go 开发的「Service of Things」平台
通过 Acceptor 模式与外部交互,支持 tcp/http/ws 等协议
以 plugin 形式嵌入 Things 功能,包括语义解析、Things action 等
用途
适用于 WOSA/XFS/LFS/PISA/... 及其它自定义协议的 Service Provider 开发
基于 Go 的交叉编译特性,适用于 Windows/Linux/MacOs ,适用于 x86/x64/arm/mips 等多种 CPU 架构
由于 WOSA/XFS/LFS/PISA... 是基于 C 语言 的 API ,因此需要 spi 库来与 gilix 服务通讯,通讯协议由 spi 决定
也可以从 WEB 浏览器通过 JS 以 ws 协议的方式,直接与 gilix 服务通讯
语义
语义解析(通过 tcp/http/ws 收到的数据解析)不包含在 gilix 中
例如 XFS/LFS/PISA 的语义解析,属于业务开发的范畴,可使用 json(推荐)、xml、其它协议等
其它
关于 XFS/LFS/PISA 等语义解析的已有实现及其它问题可私信
相关 WOSA/XFS/LFS/PISA/... 业务实现过程中,会涉及其它组件,例如 Form 解析、配置处理、test 平台(GTP)等,欢迎咨询交流
软件架构
AP 层可使用任何语言直接与 gilix 交互,只要在所支持的传输协议(tcp/http/ws/...)范围内;当然,需要针对 AP 需求来完成相匹配的 plugin 开发
AP 若使用 C/C++ 开发,则可使用所提供的 cilix_spi_ap 库来简化访问逻辑
由于 Things 不可避免的需要接入 C/C++ 的 lib 库,因此提供了 RDC 封装,与 cilix-rdc 平台远程交互
cilix_spi_ap 和 cilix-rdc 都通过 C 编写,合并在 cilix-rdc 库中
原则:两个一切
尽一切可能 的将复杂度放在 gilix (Go)
尽一切可能 的让 cilix-rdc (C) 简化
另外,gilix-util 中提供了一些实用功能,包括:
同步器 syncer
打点工作器 ticker
基于 zap 包装的日志库 zapt
...
How to Use
SOT
import "github.com/lindorof/gilix"
implement interfaces of cbs.go , such as Msg
, Dev
, Xcbs
...
import _ "github.com/lindorof/gilix/sot"
to Initialize func NewCPS
automatically
create Xcps
cps := gilix.NewCPS()
start the sot loop
cps.SotLoopSync()
create acceptor as needed
// ws
import "github.com/lindorof/gilix/acp/ws"
acceptor := ws.CreateServer(para)
// tcp
import "github.com/lindorof/gilix/acp/tcp"
acceptor := tcp.CreateServer(para)
// http
import "github.com/lindorof/gilix/acp/http"
acceptor := http.CreateServer(para)
submit acceptors to sot
cps.SubmitAcp(acceptor)
stop the sot loop on exit
cps.SotLoopBreak()
for simplicity, recommend to use syncer
import "github.com/lindorof/gilix/util"
// create syncer
syncer := util.CreateSyncer(context.Background())
// sync mode, returned when ctx cancelled
syncer.Sync(
cps.SotLoopSync(),
cps.SotLoopBreak())
// async mode, returned immediately
syncer.Async(
cps.SotLoopSync(),
cps.SotLoopBreak())
// for async mode, need to cancel and wait on exit
syncer.WaitRelease(util.SyncerWaitModeCancel)
// or just wait
syncer.WaitRelease(util.SyncerWaitModeIdle)
RDC
example for using of rdc
import "github.com/lindorof/gilix/rdc/tcp"
type para struct {
Name string
Data int
}
// in/out para
in := ¶{"Track1", 9}
out := ¶{}
// create caller
caller := tcp.CreateCaller(":8808", 5*time.Second)
// several invocations
ret, err := caller.Invoke("ReadTrack", in, out)
// destroy caller
caller.Fini()
Expand ▾
Collapse ▴
Documentation
¶
View Source
const (
HS_NIL = 0
ID_NIL = 0
TYPE_OPEN = 1
TYPE_CLOSE = 2
TYPE_REG = 3
TYPE_DEREG = 4
TYPE_INF = 5
TYPE_CMD = 6
TYPE_LOCK = 7
TYPE_UNLOCK = 8
TYPE_CANCEL = 50
TYPE_EVT_USR = 101
TYPE_EVT_SRV = 102
TYPE_EVT_EXE = 103
TYPE_EVT_SYS = 104
RET_SUCCESS = 0
RET_TIMEOUT = 1
RET_CANCELLED = 2
RET_LOCKED = 3
RET_ALREADY_LOCKED = 4
RET_NOT_LOCKED_YET = 5
RET_UNSUPP_CATEGORY = 6
RET_UNSUPP_COMMAND = 7
QUEUET_AUTO = 0
QUEUET_RT = 1
QUEUET_DF = 2
ERCV_CURRENT = 1
ERCV_LOCKER = 2
ERCV_ALL = 3
EHSU_CURRENT = 1
EHSU_LOCKER = 2
EHSU_ALL = 3
)
type DevCp interface {
PostEvt(Evt )
PollSwitch(bool )
}
type HsId interface {
Hs() HS
Id() ID
}
type ParaX interface {
Aux() PARA
Para() PARA
}
type Rsp interface {
Para() PARA
Ret() RET
}
type TypeCode interface {
Type() TYPE
Code() CODE
}
type Xcps interface {
SotLoopSync()
SotLoopBreak()
SubmitAcp(acp acp .Acceptor )
}
Source Files
¶
Directories
¶
Click to show internal directories.
Click to hide internal directories.