mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 11:14:01 +03:00
reworked hub
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
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{},
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user