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

Method LookupPartitions

dialer.go:212–238  ·  view source on GitHub ↗

LookupPartitions returns the list of partitions that exist for the given topic.

(ctx context.Context, network string, address string, topic string)

Source from the content-addressed store, hash-verified

210
211// LookupPartitions returns the list of partitions that exist for the given topic.
212func (d *Dialer) LookupPartitions(ctx context.Context, network string, address string, topic string) ([]Partition, error) {
213 conn, err := d.DialContext(ctx, network, address)
214 if err != nil {
215 return nil, err
216 }
217 defer conn.Close()
218
219 prtch := make(chan []Partition, 1)
220 errch := make(chan error, 1)
221
222 go func() {
223 if prt, err := conn.ReadPartitions(topic); err != nil {
224 errch <- err
225 } else {
226 prtch <- prt
227 }
228 }()
229
230 var prt []Partition
231 select {
232 case prt = <-prtch:
233 case err = <-errch:
234 case <-ctx.Done():
235 err = ctx.Err()
236 }
237 return prt, err
238}
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) {

Callers 4

TestDialerTLSFunction · 0.95
TestDialerResolverFunction · 0.95
LookupPartitionsFunction · 0.80

Calls 5

DialContextMethod · 0.95
DoneMethod · 0.80
CloseMethod · 0.45
ReadPartitionsMethod · 0.45
ErrMethod · 0.45

Tested by 3

TestDialerTLSFunction · 0.76
TestDialerResolverFunction · 0.76