更新
This commit is contained in:
parent
fb96268d7e
commit
bc96550885
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -9,3 +9,5 @@ example-data
|
|||
*.json
|
||||
|
||||
*.log
|
||||
|
||||
main
|
2
main.go
2
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)
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
23
unique_id.go
23
unique_id.go
|
@ -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,
|
||||
}
|
||||
}
|
|
@ -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())
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user