Change add to tryadd in dial

This commit is contained in:
mcrakhman 2023-04-12 19:16:48 +02:00 committed by Mikhail Iudin
parent 2ee3e26dd6
commit b82c7da159
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0
2 changed files with 5 additions and 1 deletions

View File

@ -28,6 +28,10 @@ func (ss *execPool) Add(ctx context.Context, f ...func()) (err error) {
return ss.batch.Add(ctx, f...)
}
func (ss *execPool) TryAdd(f ...func()) (err error) {
return ss.batch.TryAdd(f...)
}
func (ss *execPool) sendLoop() {
for {
f, err := ss.batch.WaitOne(context.Background())

View File

@ -117,7 +117,7 @@ func (s *streamPool) Send(ctx context.Context, msg drpc.Message, peerGetter Peer
}
}
}
return s.dial.Add(ctx, func() {
return s.dial.TryAdd(func() {
peers, dialErr := peerGetter(ctx)
if dialErr != nil {
log.InfoCtx(ctx, "can't get peers", zap.Error(dialErr))