diff --git a/pool/connection_pool.go b/pool/connection_pool.go index e62cb2b3e..5ae017cea 100644 --- a/pool/connection_pool.go +++ b/pool/connection_pool.go @@ -1306,7 +1306,12 @@ func (p *ConnectionPool) tryConnect(ctx context.Context, e *endpoint) error { e.role = UnknownRole connOpts := e.opts - connOpts.Notify = e.notify + if connOpts.Notify != nil { + notifyCh := make(chan tarantool.ConnEvent, 100) + go fanOut(e.closed, notifyCh, connOpts.Notify, e.notify) + connOpts.Notify = notifyCh + } + conn, err := tarantool.Connect(ctx, e.dialer, connOpts) p.poolsMutex.Lock() @@ -1542,3 +1547,23 @@ func isFeatureInSlice(expected iproto.Feature, actualSlice []iproto.Feature) boo } return false } + +func fanOut[T any](done <-chan struct{}, in <-chan T, out ...chan<- T) { + for { + select { + case <-done: + return + case v, ok := <-in: + if !ok { + return + } + + for _, ch := range out { + select { + case ch <- v: + default: + } + } + } + } +}