diff --git a/.gitignore b/.gitignore index 0cd1001..d725493 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,6 @@ example-data *.json -*.log \ No newline at end of file +*.log + +main \ No newline at end of file diff --git a/main.go b/main.go index f0b228f..2ab5c05 100644 --- a/main.go +++ b/main.go @@ -139,7 +139,7 @@ func StartNode(cfg *ConfigServer) { go func() { for DequeueHandler != nil { DequeueHandler.Notify(DequeueHandler.NULL) - time.Sleep(time.Second * 5) + time.Sleep(time.Second * 1) } }() diff --git a/sm_upate_handler.go b/sm_upate_handler.go index 9206a1e..e52d272 100644 --- a/sm_upate_handler.go +++ b/sm_upate_handler.go @@ -2,14 +2,13 @@ package fusenrender import ( "context" - "log" "github.com/474420502/execute/triggered" "github.com/474420502/passer" sm "github.com/lni/dragonboat/v4/statemachine" ) -var putCount int = 0 +var allPutCount int = 0 // 结构体异步传递后, 执行的注册函数, 实际上就是update的handler var FsPasser *passer.Passer[sm.Result] = func() *passer.Passer[sm.Result] { @@ -38,8 +37,7 @@ var FsPasser *passer.Passer[sm.Result] = func() *passer.Passer[sm.Result] { Value: cmd.Item, }) - putCount++ - log.Println("put", putCount) + allPutCount++ var result sm.Result dequeueHandler.Notify(dequeueHandler.NULL) // 通知可以执行update diff --git a/unique_id.go b/unique_id.go deleted file mode 100644 index 51d7b34..0000000 --- a/unique_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package fusenrender - -import "sync" - -type UniqueId struct { - nodeId uint64 - count uint64 - mu sync.Mutex -} - -func (uid *UniqueId) Get() uint64 { - uid.mu.Lock() - defer uid.mu.Unlock() - uid.count++ - return (uid.count << 8) | uid.nodeId -} - -func NewUniqueId(NodeId uint8) *UniqueId { - return &UniqueId{ - nodeId: uint64(NodeId), - count: 0, - } -} diff --git a/websocket.go b/websocket.go index d9ddddb..6b627f6 100644 --- a/websocket.go +++ b/websocket.go @@ -14,7 +14,6 @@ import ( "github.com/lni/dragonboat/v4/client" ) -var UidCreater = NewUniqueId(1) var PopChannel chan *QueueItem = make(chan *QueueItem, 100) // chan *QueueItem = make(chan *QueueItem, 1) var upgrader = websocket.Upgrader{ @@ -72,7 +71,7 @@ func queueHandler(w http.ResponseWriter, r *http.Request) { } } - err = conn.SetWriteDeadline(time.Now().Add(time.Second * 6)) + err = conn.SetWriteDeadline(time.Now().Add(time.Second * 4)) if err != nil { log.Println(err) log.Println("重新回队") @@ -88,8 +87,9 @@ func queueHandler(w http.ResponseWriter, r *http.Request) { stateClient.PushItem(nil, item) return } + count++ - log.Println("count:", count) + log.Printf("count: %d all put: %d", count, allPutCount) // 打印消息 log.Printf("source: [%s] 数据 推送到unity [%s]\n", item.Source, raddr.String()) diff --git a/websocket_test.go b/websocket_test.go index 09412e9..54199e4 100644 --- a/websocket_test.go +++ b/websocket_test.go @@ -38,7 +38,7 @@ func TestWebsocketC(t *testing.T) { fusenrender.StartNode(svc) } -var addr = "api.fusen.3718.cn:4050" +var addr = "server.fusen.3718.cn:4050" // var addr = "localhost:4050"