test: dispatcher 包完善测试用例

This commit is contained in:
kercylan98 2024-01-12 16:34:28 +08:00
parent 90b7e4c1f8
commit 6f7868483f
1 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package dispatcher_test
import (
"fmt"
"github.com/kercylan98/minotaur/server/internal/dispatcher"
)
func ExampleNewManager() {
mgr := dispatcher.NewManager[string, *TestMessage](10124*16, func(dispatcher *dispatcher.Dispatcher[string, *TestMessage], message *TestMessage) {
// do something
})
mgr.BindProducer("player_001", "shunt-001")
mgr.BindProducer("player_002", "shunt-002")
mgr.BindProducer("player_003", "shunt-sys")
mgr.BindProducer("player_004", "shunt-sys")
mgr.UnBindProducer("player_001")
mgr.UnBindProducer("player_002")
mgr.UnBindProducer("player_003")
mgr.UnBindProducer("player_004")
mgr.Wait()
fmt.Println("done")
// Output: done
}