FILE / ScuroNeko/mtg

hub/init.go

Исходный файл и его история в репозитории.
FILE 6c7edfb7db1028c73cb5990866dafcfdef998824
Files
mtg/hub/init.go
T
2019-10-07 17:26:03 +03:00

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 = &registry{
conns: map[string]*ctxChannel{},
ctx: ctx,
}
Hub = &hub{
subs: map[string]*connectionHub{},
}
})
}