LookupPartitions returns the list of partitions that exist for the given topic.
(ctx context.Context, network string, address string, topic string)
| 210 | |
| 211 | // LookupPartitions returns the list of partitions that exist for the given topic. |
| 212 | func (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. |
| 241 | func (d *Dialer) connectTLS(ctx context.Context, conn net.Conn, config *tls.Config) (tlsConn *tls.Conn, err error) { |