This commit is contained in:
eson 2023-11-14 10:50:56 +08:00
parent fb96268d7e
commit bc96550885
6 changed files with 10 additions and 33 deletions

2
.gitignore vendored
View File

@ -9,3 +9,5 @@ example-data
*.json *.json
*.log *.log
main

View File

@ -139,7 +139,7 @@ func StartNode(cfg *ConfigServer) {
go func() { go func() {
for DequeueHandler != nil { for DequeueHandler != nil {
DequeueHandler.Notify(DequeueHandler.NULL) DequeueHandler.Notify(DequeueHandler.NULL)
time.Sleep(time.Second * 5) time.Sleep(time.Second * 1)
} }
}() }()

View File

@ -2,14 +2,13 @@ package fusenrender
import ( import (
"context" "context"
"log"
"github.com/474420502/execute/triggered" "github.com/474420502/execute/triggered"
"github.com/474420502/passer" "github.com/474420502/passer"
sm "github.com/lni/dragonboat/v4/statemachine" sm "github.com/lni/dragonboat/v4/statemachine"
) )
var putCount int = 0 var allPutCount int = 0
// 结构体异步传递后, 执行的注册函数, 实际上就是update的handler // 结构体异步传递后, 执行的注册函数, 实际上就是update的handler
var FsPasser *passer.Passer[sm.Result] = func() *passer.Passer[sm.Result] { 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, Value: cmd.Item,
}) })
putCount++ allPutCount++
log.Println("put", putCount)
var result sm.Result var result sm.Result
dequeueHandler.Notify(dequeueHandler.NULL) // 通知可以执行update dequeueHandler.Notify(dequeueHandler.NULL) // 通知可以执行update

View File

@ -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,
}
}

View File

@ -14,7 +14,6 @@ import (
"github.com/lni/dragonboat/v4/client" "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 PopChannel chan *QueueItem = make(chan *QueueItem, 100) // chan *QueueItem = make(chan *QueueItem, 1)
var upgrader = websocket.Upgrader{ 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 { if err != nil {
log.Println(err) log.Println(err)
log.Println("重新回队") log.Println("重新回队")
@ -88,8 +87,9 @@ func queueHandler(w http.ResponseWriter, r *http.Request) {
stateClient.PushItem(nil, item) stateClient.PushItem(nil, item)
return return
} }
count++ 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()) log.Printf("source: [%s] 数据 推送到unity [%s]\n", item.Source, raddr.String())

View File

@ -38,7 +38,7 @@ func TestWebsocketC(t *testing.T) {
fusenrender.StartNode(svc) fusenrender.StartNode(svc)
} }
var addr = "api.fusen.3718.cn:4050" var addr = "server.fusen.3718.cn:4050"
// var addr = "localhost:4050" // var addr = "localhost:4050"