-
Notifications
You must be signed in to change notification settings - Fork 1
/
mycontext.go
66 lines (63 loc) · 1.86 KB
/
mycontext.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
type MyContext struct {
AuthService AuthService
UserStore UserStore
PasswordStore PasswordStore
RoomStore RoomStore
RoomProvider RoomProvider
RoomProviderGC RoomProviderGC
RTMT RealtimeMessageTransport
Hub *Hub
}
func newMyContextForTest() *MyContext {
userStore := newUserStoreImpl()
passwordStore := newPasswordStoreImpl()
authService := newAuthServiceImpl()
authService.SetUserStore(userStore)
authService.SetPasswordStore(passwordStore)
roomStore := NewRoomStoreImpl()
roomProvider := NewRoomProviderImpl(roomStore)
roomProviderGC := NewRoomProviderGCImpl(roomProvider, userStore)
rtmt := NewRealtimeMessageTransportWebSocket()
rtmt.ListenTestChannel()
hub := NewHub()
go hub.Run()
go hub.HandleMessage()
return &MyContext{
UserStore: userStore,
PasswordStore: passwordStore,
AuthService: authService,
RoomStore: roomStore,
RoomProvider: roomProvider,
RoomProviderGC: roomProviderGC,
RTMT: rtmt,
Hub: hub,
}
}
func newMyContext() *MyContext {
options := getDatabaseConnectionVariables()
db := CreateDatabaseConnection(options)
userStore := newUserStoreDBImpl(db)
passwordStore := newPasswordStoreDBImpl(db)
authService := newAuthServiceImpl()
authService.SetUserStore(userStore)
authService.SetPasswordStore(passwordStore)
roomStore := NewRoomStoreDatabaseImpl(db)
roomProvider := NewRoomProviderImpl(roomStore)
roomProviderGC := NewRoomProviderGCImpl(roomProvider, userStore)
rtmt := NewRealtimeMessageTransportWebSocket()
rtmt.ListenTestChannel()
hub := NewHub()
go hub.Run()
go hub.HandleMessage()
return &MyContext{
UserStore: userStore,
PasswordStore: passwordStore,
AuthService: authService,
RoomStore: roomStore,
RoomProvider: roomProvider,
RoomProviderGC: roomProviderGC,
RTMT: rtmt,
Hub: hub,
}
}