MCPcopy
hub / github.com/segmentio/kafka-go / connectTLS

Method connectTLS

dialer.go:241–261  ·  view source on GitHub ↗

connectTLS returns a tls.Conn that has already completed the Handshake.

(ctx context.Context, conn net.Conn, config *tls.Config)

Source from the content-addressed store, hash-verified

239
240// connectTLS returns a tls.Conn that has already completed the Handshake.
241func (d *Dialer) connectTLS(ctx context.Context, conn net.Conn, config *tls.Config) (tlsConn *tls.Conn, err error) {
242 tlsConn = tls.Client(conn, config)
243 errch := make(chan error)
244
245 go func() {
246 defer close(errch)
247 errch <- tlsConn.Handshake()
248 }()
249
250 select {
251 case <-ctx.Done():
252 conn.Close()
253 tlsConn.Close()
254 <-errch // ignore possible error from Handshake
255 err = ctx.Err()
256
257 case err = <-errch:
258 }
259
260 return
261}
262
263// connect opens a socket connection to the broker, wraps it to create a
264// kafka connection, and performs SASL authentication if configured to do so.

Callers 2

dialContextMethod · 0.95

Calls 3

DoneMethod · 0.80
CloseMethod · 0.45
ErrMethod · 0.45

Tested by 1