Remove app initialization from WebHub (#18687)
- Make it a Server method. - Pass Server instead of App. - Remove global app instance from NewServer, rather create local instances whenever needed. - Remove App from Websocket router, and create dynamically on every request. - Remove HubStart and HubStop from App methods. - Explicitly using s.Log instead of the global logger to indicate dependency on Server. We could have passed the logger explicitly but it doesn't look ideal. ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
609fea0002
Коммит
d949bd1638
@@ -66,7 +66,7 @@ func TestHubStopWithMultipleConnections(t *testing.T) {
|
||||
s := httptest.NewServer(dummyWebsocketHandler(t))
|
||||
defer s.Close()
|
||||
|
||||
th.App.HubStart()
|
||||
th.Server.HubStart()
|
||||
wc1 := registerDummyWebConn(t, th.App, s.Listener.Addr(), th.BasicUser.Id)
|
||||
wc2 := registerDummyWebConn(t, th.App, s.Listener.Addr(), th.BasicUser.Id)
|
||||
wc3 := registerDummyWebConn(t, th.App, s.Listener.Addr(), th.BasicUser.Id)
|
||||
@@ -84,12 +84,12 @@ func TestHubStopRaceCondition(t *testing.T) {
|
||||
// So we just use this quick hack for the test.
|
||||
s := httptest.NewServer(dummyWebsocketHandler(t))
|
||||
|
||||
th.App.HubStart()
|
||||
th.Server.HubStart()
|
||||
wc1 := registerDummyWebConn(t, th.App, s.Listener.Addr(), th.BasicUser.Id)
|
||||
defer wc1.Close()
|
||||
|
||||
hub := th.App.Srv().hubs[0]
|
||||
th.App.HubStop()
|
||||
th.Server.HubStop()
|
||||
|
||||
done := make(chan bool)
|
||||
go func() {
|
||||
@@ -347,7 +347,7 @@ func TestHubIsRegistered(t *testing.T) {
|
||||
s := httptest.NewServer(dummyWebsocketHandler(t))
|
||||
defer s.Close()
|
||||
|
||||
th.App.HubStart()
|
||||
th.Server.HubStart()
|
||||
wc1 := registerDummyWebConn(t, th.App, s.Listener.Addr(), th.BasicUser.Id)
|
||||
wc2 := registerDummyWebConn(t, th.App, s.Listener.Addr(), th.BasicUser.Id)
|
||||
wc3 := registerDummyWebConn(t, th.App, s.Listener.Addr(), th.BasicUser.Id)
|
||||
@@ -418,7 +418,7 @@ func BenchmarkGetHubForUserId(b *testing.B) {
|
||||
th := Setup(b).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.HubStart()
|
||||
th.Server.HubStart()
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
||||
Ссылка в новой задаче
Block a user