Correct multiplexing

This commit is contained in:
9seconds
2019-11-11 14:04:15 +03:00
parent 0ff9a58780
commit 22905b2a25
19 changed files with 445 additions and 436 deletions
+5 -14
View File
@@ -4,30 +4,21 @@ 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")
ErrTimeout = errors.New("timeout")
ErrClosed = errors.New("context is closed")
Hub Interface
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"),
muxes: make(map[int32]*mux),
ctx: ctx,
}
})
}