mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 23:14:02 +03:00
FILE / ScuroNeko/mtg
hub/init.go
Исходный файл и его история в репозитории.
31 lines
497 B
Go
31 lines
497 B
Go
package hub
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"sync"
|
|
)
|
|
|
|
var (
|
|
Registry *registry
|
|
Hub *hub
|
|
|
|
ErrTimeout = errors.New("timeout")
|
|
ErrClosed = errors.New("channel was closed")
|
|
ErrCannotCreateConnection = errors.New("cannot create connection")
|
|
|
|
initOnce sync.Once
|
|
)
|
|
|
|
func Init(ctx context.Context) {
|
|
initOnce.Do(func() {
|
|
Registry = ®istry{
|
|
conns: map[string]*ctxChannel{},
|
|
ctx: ctx,
|
|
}
|
|
Hub = &hub{
|
|
subs: map[string]*connectionHub{},
|
|
}
|
|
})
|
|
}
|