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

Function ExamplePartitioner_per_topic

partitioner_test.go:494–507  ·  view source on GitHub ↗

This example shows how to set a different partitioner depending on the topic.

()

Source from the content-addressed store, hash-verified

492
493// This example shows how to set a different partitioner depending on the topic.
494func ExamplePartitioner_per_topic() {
495 config := NewTestConfig()
496 config.Producer.Partitioner = func(topic string) Partitioner {
497 switch topic {
498 case "access_log", "error_log":
499 return NewRandomPartitioner(topic)
500
501 default:
502 return NewHashPartitioner(topic)
503 }
504 }
505
506 // ...
507}

Callers

nothing calls this directly

Calls 3

NewRandomPartitionerFunction · 0.85
NewHashPartitionerFunction · 0.85
NewTestConfigFunction · 0.70

Tested by

no test coverage detected