-
Notifications
You must be signed in to change notification settings - Fork 453
/
static.go
38 lines (30 loc) · 1.04 KB
/
static.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
package session
import (
"context"
)
var DefaultSessionPool SessionPool
// GetSessionByUID return a session bound to an user id
func GetSessionByUID(uid string) Session {
return DefaultSessionPool.GetSessionByUID(uid)
}
// GetSessionByID return a session bound to a frontend server id
func GetSessionByID(id int64) Session {
return DefaultSessionPool.GetSessionByID(id)
}
// OnSessionBind adds a method to be called when a session is bound
// same function cannot be added twice!
func OnSessionBind(f func(ctx context.Context, s Session) error) {
DefaultSessionPool.OnSessionBind(f)
}
// OnAfterSessionBind adds a method to be called when session is bound and after all sessionBind callbacks
func OnAfterSessionBind(f func(ctx context.Context, s Session) error) {
DefaultSessionPool.OnAfterSessionBind(f)
}
// OnSessionClose adds a method that will be called when every session closes
func OnSessionClose(f func(s Session)) {
DefaultSessionPool.OnSessionClose(f)
}
// CloseAll calls Close on all sessions
func CloseAll() {
DefaultSessionPool.CloseAll()
}