ExampleNewReader_rackAffinity shows how the RackAffinityGroupBalancer can be used to pair up consumers with brokers in the same AWS availability zone. This code assumes that each brokers' rack is configured to be the name of the AZ in which it is running.
()
| 15 | // This code assumes that each brokers' rack is configured to be the name of the |
| 16 | // AZ in which it is running. |
| 17 | func ExampleNewReader_rackAffinity() { |
| 18 | r := NewReader(ReaderConfig{ |
| 19 | Brokers: []string{"kafka:9092"}, |
| 20 | GroupID: "my-group", |
| 21 | Topic: "my-topic", |
| 22 | GroupBalancers: []GroupBalancer{ |
| 23 | RackAffinityGroupBalancer{Rack: findRack()}, |
| 24 | RangeGroupBalancer{}, |
| 25 | }, |
| 26 | }) |
| 27 | |
| 28 | r.ReadMessage(context.Background()) |
| 29 | |
| 30 | r.Close() |
| 31 | } |
| 32 | |
| 33 | // findRack is the basic rack resolver strategy for use in AWS. It supports |
| 34 | // * ECS with the task metadata endpoint enabled (returns the container |
nothing calls this directly
no test coverage detected
searching dependent graphs…