FILE / ScuroNeko/mtg

hub/init.go

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

34 lines
552 B
Go

package hub
import (
"context"
"errors"
"sync"
"go.uber.org/zap"
)
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{},
logger: zap.S().Named("hub"),
}
})
}