MCPcopy
hub / github.com/IBM/sarama / ExampleBroker

Function ExampleBroker

broker_test.go:20–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18)
19
20func ExampleBroker() {
21 broker := NewBroker("localhost:9092")
22 err := broker.Open(nil)
23 if err != nil {
24 panic(err)
25 }
26
27 request := MetadataRequest{Topics: []string{"myTopic"}}
28 response, err := broker.GetMetadata(&request)
29 if err != nil {
30 _ = broker.Close()
31 panic(err)
32 }
33
34 fmt.Println("There are", len(response.Topics), "topics active in the cluster.")
35
36 if err = broker.Close(); err != nil {
37 panic(err)
38 }
39}
40
41type mockEncoder struct {
42 bytes []byte

Callers

nothing calls this directly

Calls 5

OpenMethod · 0.95
GetMetadataMethod · 0.95
CloseMethod · 0.95
NewBrokerFunction · 0.85
PrintlnMethod · 0.65

Tested by

no test coverage detected