mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
修改ws版本以及结点优化
This commit is contained in:
2
go.mod
2
go.mod
@@ -12,7 +12,7 @@ require (
|
|||||||
github.com/goccy/go-json v0.10.2
|
github.com/goccy/go-json v0.10.2
|
||||||
github.com/gomodule/redigo v1.8.8
|
github.com/gomodule/redigo v1.8.8
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/gorilla/websocket v1.5.0
|
github.com/gorilla/websocket v1.5.3
|
||||||
github.com/json-iterator/go v1.1.12
|
github.com/json-iterator/go v1.1.12
|
||||||
github.com/nats-io/nats.go v1.34.1
|
github.com/nats-io/nats.go v1.34.1
|
||||||
github.com/pierrec/lz4/v4 v4.1.21
|
github.com/pierrec/lz4/v4 v4.1.21
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -88,8 +88,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
|||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
|
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
|
||||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Blueprint struct {
|
type Blueprint struct {
|
||||||
|
execNodes []IExecNode // 注册的定义执行结点
|
||||||
|
|
||||||
execPool ExecPool
|
execPool ExecPool
|
||||||
graphPool GraphPool
|
graphPool GraphPool
|
||||||
|
|
||||||
@@ -15,13 +17,51 @@ type Blueprint struct {
|
|||||||
cancelTimer func(*uint64)bool
|
cancelTimer func(*uint64)bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (bm *Blueprint) RegExecNode(execNode IExecNode) {
|
||||||
|
bm.execNodes = append(bm.execNodes, execNode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bm *Blueprint) regSysNode(){
|
||||||
|
bm.RegExecNode(&AddInt{})
|
||||||
|
bm.RegExecNode(&SubInt{})
|
||||||
|
bm.RegExecNode(&MulInt{})
|
||||||
|
bm.RegExecNode(&DivInt{})
|
||||||
|
bm.RegExecNode(&ModInt{})
|
||||||
|
bm.RegExecNode(&RandNumber{})
|
||||||
|
|
||||||
|
bm.RegExecNode(&Entrance_ArrayParam{})
|
||||||
|
bm.RegExecNode(&Entrance_IntParam{})
|
||||||
|
bm.RegExecNode(&Entrance_Timer{})
|
||||||
|
bm.RegExecNode(&Output{})
|
||||||
|
bm.RegExecNode(&Sequence{})
|
||||||
|
bm.RegExecNode(&Foreach{})
|
||||||
|
bm.RegExecNode(&ForeachIntArray{})
|
||||||
|
|
||||||
|
bm.RegExecNode(&GetArrayInt{})
|
||||||
|
bm.RegExecNode(&GetArrayString{})
|
||||||
|
bm.RegExecNode(&GetArrayLen{})
|
||||||
|
bm.RegExecNode(&CreateIntArray{})
|
||||||
|
bm.RegExecNode(&CreateStringArray{})
|
||||||
|
bm.RegExecNode(&AppendIntegerToArray{})
|
||||||
|
bm.RegExecNode(&AppendStringToArray{})
|
||||||
|
|
||||||
|
bm.RegExecNode(&BoolIf{})
|
||||||
|
bm.RegExecNode(&GreaterThanInteger{})
|
||||||
|
bm.RegExecNode(&LessThanInteger{})
|
||||||
|
bm.RegExecNode(&EqualInteger{})
|
||||||
|
bm.RegExecNode(&RangeCompare{})
|
||||||
|
bm.RegExecNode(&Probability{})
|
||||||
|
bm.RegExecNode(&CreateTimer{})
|
||||||
|
}
|
||||||
|
|
||||||
func (bm *Blueprint) Init(execDefFilePath string, graphFilePath string, blueprintModule IBlueprintModule,cancelTimer func(*uint64)bool) error {
|
func (bm *Blueprint) Init(execDefFilePath string, graphFilePath string, blueprintModule IBlueprintModule,cancelTimer func(*uint64)bool) error {
|
||||||
|
bm.regSysNode()
|
||||||
err := bm.execPool.Load(execDefFilePath)
|
err := bm.execPool.Load(execDefFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, e := range execNodes {
|
for _, e := range bm.execNodes {
|
||||||
if !bm.execPool.Register(e) {
|
if !bm.execPool.Register(e) {
|
||||||
return fmt.Errorf("register exec failed,exec:%s", e.GetName())
|
return fmt.Errorf("register exec failed,exec:%s", e.GetName())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,6 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
RegExecNode(&AddInt{})
|
|
||||||
RegExecNode(&SubInt{})
|
|
||||||
RegExecNode(&MulInt{})
|
|
||||||
RegExecNode(&DivInt{})
|
|
||||||
RegExecNode(&ModInt{})
|
|
||||||
RegExecNode(&RandNumber{})
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddInt 加(int)
|
// AddInt 加(int)
|
||||||
type AddInt struct {
|
type AddInt struct {
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
package blueprint
|
package blueprint
|
||||||
|
|
||||||
var execNodes []IExecNode
|
|
||||||
|
|
||||||
func RegExecNode(exec IExecNode) {
|
|
||||||
execNodes = append(execNodes, exec)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,31 +15,7 @@ const (
|
|||||||
EntranceID_Timer = 3
|
EntranceID_Timer = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
RegExecNode(&Entrance_ArrayParam{})
|
|
||||||
RegExecNode(&Entrance_IntParam{})
|
|
||||||
RegExecNode(&Entrance_Timer{})
|
|
||||||
RegExecNode(&Output{})
|
|
||||||
RegExecNode(&Sequence{})
|
|
||||||
RegExecNode(&Foreach{})
|
|
||||||
RegExecNode(&ForeachIntArray{})
|
|
||||||
|
|
||||||
RegExecNode(&GetArrayInt{})
|
|
||||||
RegExecNode(&GetArrayString{})
|
|
||||||
RegExecNode(&GetArrayLen{})
|
|
||||||
RegExecNode(&CreateIntArray{})
|
|
||||||
RegExecNode(&CreateStringArray{})
|
|
||||||
RegExecNode(&AppendIntegerToArray{})
|
|
||||||
RegExecNode(&AppendStringToArray{})
|
|
||||||
|
|
||||||
RegExecNode(&BoolIf{})
|
|
||||||
RegExecNode(&GreaterThanInteger{})
|
|
||||||
RegExecNode(&LessThanInteger{})
|
|
||||||
RegExecNode(&EqualInteger{})
|
|
||||||
RegExecNode(&RangeCompare{})
|
|
||||||
RegExecNode(&Probability{})
|
|
||||||
RegExecNode(&CreateTimer{})
|
|
||||||
}
|
|
||||||
|
|
||||||
type Entrance_ArrayParam struct {
|
type Entrance_ArrayParam struct {
|
||||||
BaseExecNode
|
BaseExecNode
|
||||||
|
|||||||
Reference in New Issue
Block a user