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

Function TestClientFindCoordinator

findcoordinator_test.go:44–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestClientFindCoordinator(t *testing.T) {
45 client, shutdown := newLocalClient()
46 defer shutdown()
47
48 ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
49 defer cancel()
50 resp, err := waitForCoordinatorIndefinitely(ctx, client, &FindCoordinatorRequest{
51 Addr: client.Addr,
52 Key: "TransactionalID-1",
53 KeyType: CoordinatorKeyTypeTransaction,
54 })
55 if err != nil {
56 t.Fatal(err)
57 }
58
59 if resp.Coordinator.Host != "localhost" {
60 t.Fatal("Coordinator should be found @ localhost")
61 }
62}
63
64// WaitForCoordinatorIndefinitely is a blocking call till a coordinator is found.
65func waitForCoordinatorIndefinitely(ctx context.Context, c *Client, req *FindCoordinatorRequest) (*FindCoordinatorResponse, error) {

Callers

nothing calls this directly

Calls 2

newLocalClientFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…