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

Function TestMurmur2PartitionerConsistency

partitioner_test.go:414–427  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

412}
413
414func TestMurmur2PartitionerConsistency(t *testing.T) {
415 partitioner := NewMurmur2Partitioner("mytopic")
416 ep, ok := partitioner.(DynamicConsistencyPartitioner)
417 if !ok {
418 t.Fatal("murmur2 partitioner does not implement DynamicConsistencyPartitioner")
419 }
420
421 if !ep.MessageRequiresConsistency(&ProducerMessage{Key: StringEncoder("hi")}) {
422 t.Error("messages with keys should require consistency")
423 }
424 if ep.MessageRequiresConsistency(&ProducerMessage{}) {
425 t.Error("messages without keys should not require consistency")
426 }
427}
428
429// By default, Sarama uses the message's key to consistently assign a partition to
430// a message using hashing. If no key is set, a random partition will be chosen.

Callers

nothing calls this directly

Calls 5

NewMurmur2PartitionerFunction · 0.85
StringEncoderTypeAlias · 0.85
FatalMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected