engine

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: AGPL-3.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRuleEngine typex.RuleX

* * 全局默认引擎,未来主要留给外部使用 *

Functions

func InitRuleEngine added in v0.6.3

func InitRuleEngine(config typex.RulexConfig) typex.RuleX

func LoadBuildInLuaLib

func LoadBuildInLuaLib(e typex.RuleX, r *typex.Rule)

* * 加载标准库, 为什么是每个LUA脚本都加载一次?主要是为了隔离,互不影响 *

func LoadExtLuaLib

func LoadExtLuaLib(e typex.RuleX, r *typex.Rule) error

* * 加载外部扩展库 *

func RunRulex

func RunRulex(iniPath string)

启动 Rulex

Types

type Filer added in v0.6.1

type Filer interface {
	File() (f *os.File, err error)
}

Filer 获取 os.File

type Process added in v0.6.1

type Process struct {
	Name       string         // 要加载的可执行文件路径
	Listener   []net.Listener // 要继承的链接
	Env        bool           // 是否继承环境变量?
	ExcludeEnv []string       // 要忽略的环境变量key
	Argv       []string       // 传递给新进程的命令行参数
}

/ Process 进程参数

func (Process) Start added in v0.6.1

func (p Process) Start() (int, error)

Start 启动新的进程

type RuleEngine

type RuleEngine struct {
	Hooks   *sync.Map          `json:"hooks"`
	Rules   *sync.Map          `json:"rules"`
	Plugins *sync.Map          `json:"plugins"`
	InEnds  *sync.Map          `json:"inends"`
	OutEnds *sync.Map          `json:"outends"`
	Drivers *sync.Map          `json:"drivers"`
	Devices *sync.Map          `json:"devices"`
	Config  *typex.RulexConfig `json:"config"`
	// 规划在0.7的时候将下面这些组件和RULE Engine解耦合
	// |||||||||||||||||||||||||||||||||||||||||||||
	// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
	Trailer           typex.XTrailer          `json:"-"` // 待迁移组件
	AppStack          typex.XAppStack         `json:"-"` // 待迁移组件
	AiBaseRuntime     typex.XAiRuntime        `json:"-"` // 待迁移组件
	DeviceTypeManager typex.DeviceRegistry    `json:"-"` // 待迁移组件
	SourceTypeManager typex.SourceRegistry    `json:"-"` // 待迁移组件
	TargetTypeManager typex.TargetRegistry    `json:"-"` // 待迁移组件
	MetricStatistics  *typex.MetricStatistics // 待迁移组件
}

规则引擎

func (*RuleEngine) AllApp

func (e *RuleEngine) AllApp() []*typex.Application

* * 都是一些对应用的CURD *

func (*RuleEngine) AllDevices

func (e *RuleEngine) AllDevices() *sync.Map

获取所有外挂设备

func (*RuleEngine) AllGoods

func (e *RuleEngine) AllGoods() *sync.Map

所有外部驱动

func (*RuleEngine) AllInEnd

func (e *RuleEngine) AllInEnd() *sync.Map

func (*RuleEngine) AllOutEnd

func (e *RuleEngine) AllOutEnd() *sync.Map

func (*RuleEngine) AllPlugins

func (e *RuleEngine) AllPlugins() *sync.Map

func (*RuleEngine) AllRule

func (e *RuleEngine) AllRule() *sync.Map

func (*RuleEngine) GetAiBase

func (e *RuleEngine) GetAiBase() typex.XAiRuntime

func (*RuleEngine) GetApp

func (e *RuleEngine) GetApp(uuid string) *typex.Application

func (*RuleEngine) GetConfig

func (e *RuleEngine) GetConfig() *typex.RulexConfig

func (*RuleEngine) GetDevice

func (e *RuleEngine) GetDevice(id string) *typex.Device

获取设备

func (*RuleEngine) GetGoods

func (e *RuleEngine) GetGoods(uuid string) *typex.Goods

获取某个外部驱动信息

func (*RuleEngine) GetInEnd

func (e *RuleEngine) GetInEnd(uuid string) *typex.InEnd

func (*RuleEngine) GetMetricStatistics added in v0.6.1

func (e *RuleEngine) GetMetricStatistics() *typex.MetricStatistics

func (*RuleEngine) GetOutEnd

func (e *RuleEngine) GetOutEnd(id string) *typex.OutEnd

func (*RuleEngine) GetPlugins

func (e *RuleEngine) GetPlugins() *sync.Map

func (*RuleEngine) GetRule

func (e *RuleEngine) GetRule(id string) *typex.Rule

GetRule a rule

func (*RuleEngine) InitDeviceTypeManager

func (e *RuleEngine) InitDeviceTypeManager() error

* * 初始化设备管理器 *

func (*RuleEngine) InitSourceTypeManager

func (e *RuleEngine) InitSourceTypeManager() error

* * 初始化输入资源管理器 *

func (*RuleEngine) InitTargetTypeManager

func (e *RuleEngine) InitTargetTypeManager() error

* * 初始化输出资源管理器 *

func (*RuleEngine) LoadApp

func (e *RuleEngine) LoadApp(app *typex.Application) error

func (*RuleEngine) LoadBuiltInEnd

func (e *RuleEngine) LoadBuiltInEnd(in *typex.InEnd) error

* * 内建资源 *

func (*RuleEngine) LoadDeviceWithCtx added in v0.5.2

func (e *RuleEngine) LoadDeviceWithCtx(deviceInfo *typex.Device,
	ctx context.Context, cancelCTX context.CancelFunc) error

* * 加载设备 *

func (*RuleEngine) LoadGoods

func (e *RuleEngine) LoadGoods(goods typex.Goods) error

* * 加载外部程序 *

func (*RuleEngine) LoadHook

func (e *RuleEngine) LoadHook(h typex.XHook) error

LoadHook

func (*RuleEngine) LoadInEndWithCtx added in v0.5.2

func (e *RuleEngine) LoadInEndWithCtx(in *typex.InEnd,
	ctx context.Context, cancelCTX context.CancelFunc) error

* * 加载输入资源 *

func (*RuleEngine) LoadOutEndWithCtx added in v0.5.2

func (e *RuleEngine) LoadOutEndWithCtx(in *typex.OutEnd, ctx context.Context,
	cancelCTX context.CancelFunc) error

func (*RuleEngine) LoadPlugin

func (e *RuleEngine) LoadPlugin(sectionK string, p typex.XPlugin) error

┌──────┐ ┌──────┐ ┌──────┐ │ Init ├───►│ Load ├───►│ Stop │ └──────┘ └──────┘ └──────┘

func (*RuleEngine) LoadRule

func (e *RuleEngine) LoadRule(r *typex.Rule) error

LoadRule: 每个规则都绑定了资源(FromSource)或者设备(FromDevice) 使用MAP来记录RULE的绑定关系, KEY是UUID, Value是规则

func (*RuleEngine) LoadUserInEnd

func (e *RuleEngine) LoadUserInEnd(source typex.XSource, in *typex.InEnd) error

* * 加载用户资源 *

func (*RuleEngine) PickUpProcess

func (e *RuleEngine) PickUpProcess(uuid string) *typex.GoodsProcess

取一个进程

func (*RuleEngine) RemoveApp

func (e *RuleEngine) RemoveApp(uuid string) error

func (*RuleEngine) RemoveDevice

func (e *RuleEngine) RemoveDevice(uuid string)

删除设备

func (*RuleEngine) RemoveGoods

func (e *RuleEngine) RemoveGoods(uuid string) error

删除外部驱动

func (*RuleEngine) RemoveInEnd

func (e *RuleEngine) RemoveInEnd(id string)

func (*RuleEngine) RemoveOutEnd

func (e *RuleEngine) RemoveOutEnd(uuid string)

func (*RuleEngine) RemoveRule

func (e *RuleEngine) RemoveRule(ruleId string)

RemoveRule and inend--rule bindings

func (*RuleEngine) RestartDevice

func (e *RuleEngine) RestartDevice(uuid string) error

重启设备

func (*RuleEngine) RestartInEnd

func (e *RuleEngine) RestartInEnd(uuid string) error

重启源

func (*RuleEngine) RestartOutEnd

func (e *RuleEngine) RestartOutEnd(uuid string) error

重启目标

func (*RuleEngine) RunDeviceCallbacks

func (e *RuleEngine) RunDeviceCallbacks(Device *typex.Device, callbackArgs string)

* * 执行针对设备端的规则脚本 *

func (*RuleEngine) RunHooks

func (e *RuleEngine) RunHooks(data string)

RunHooks

func (*RuleEngine) RunSourceCallbacks

func (e *RuleEngine) RunSourceCallbacks(in *typex.InEnd, callbackArgs string)

* * 执行针对资源端的规则脚本 *

func (*RuleEngine) SaveDevice

func (e *RuleEngine) SaveDevice(dev *typex.Device)

保存设备

func (*RuleEngine) SaveInEnd

func (e *RuleEngine) SaveInEnd(in *typex.InEnd)

func (*RuleEngine) SaveOutEnd

func (e *RuleEngine) SaveOutEnd(out *typex.OutEnd)

func (*RuleEngine) SaveRule

func (e *RuleEngine) SaveRule(r *typex.Rule)

func (*RuleEngine) SnapshotDump

func (e *RuleEngine) SnapshotDump() string

----------------------------------------------------------------- 获取运行时快照 -----------------------------------------------------------------

func (*RuleEngine) Start

func (e *RuleEngine) Start() *typex.RulexConfig

func (*RuleEngine) StartApp

func (e *RuleEngine) StartApp(uuid string) error

func (*RuleEngine) Stop

func (e *RuleEngine) Stop()

Stop

func (*RuleEngine) StopApp

func (e *RuleEngine) StopApp(uuid string) error

func (*RuleEngine) Version

func (e *RuleEngine) Version() typex.Version

func (*RuleEngine) Wait added in v0.6.1

func (e *RuleEngine) Wait(signals ...os.Signal)

Wait 阻塞当前进程,等待关闭信号

func (*RuleEngine) WorkDevice

func (e *RuleEngine) WorkDevice(Device *typex.Device, data string) (bool, error)

核心功能: Work, 主要就是推流进队列

func (*RuleEngine) WorkInEnd

func (e *RuleEngine) WorkInEnd(in *typex.InEnd, data string) (bool, error)

核心功能: Work, 主要就是推流进队列

Jump to

Keyboard shortcuts

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