Skip to content

Commit

Permalink
dial instead of waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunKoyalwar committed May 9, 2024
1 parent dd1cec4 commit 6e4e04d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fastdialer/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fastdialer

import (
"context"
"math/rand"
"net"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -281,6 +282,16 @@ func (d *l4ConnHandler) getConn(ctx context.Context) (net.Conn, string, error) {
continue
}
return res.conn, res.ip, res.err
// need to rework this part
case d.poolingChan <- func() *dialResult {
index := rand.Intn(len(d.ips))
ip := d.ips[index]
d.fd.acquire() // no-op if max open connections is not set
conn, err := d.fd.simpleDialer.Dial(ctx, d.network, net.JoinHostPort(ip, d.port))
conn = d.fd.releaseWithHook(conn)
return &dialResult{conn, err, ip}
}():
continue
}
}
}
Expand Down

0 comments on commit 6e4e04d

Please sign in to comment.