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

Function testConnReadWatermarkFromBatch

conn_test.go:549–575  ·  view source on GitHub ↗
(t *testing.T, conn *Conn)

Source from the content-addressed store, hash-verified

547}
548
549func testConnReadWatermarkFromBatch(t *testing.T, conn *Conn) {
550 if _, err := conn.WriteMessages(makeTestSequence(10)...); err != nil {
551 t.Fatal(err)
552 }
553
554 const minBytes = 1
555 const maxBytes = 10e6 // 10 MB
556
557 value := make([]byte, 10e3) // 10 KB
558
559 batch := conn.ReadBatch(minBytes, maxBytes)
560
561 for i := 0; i < 10; i++ {
562 _, err := batch.Read(value)
563 if err != nil {
564 if err = batch.Close(); err != nil {
565 t.Fatalf("error trying to read batch message: %s", err)
566 }
567 }
568
569 if batch.HighWaterMark() != 10 {
570 t.Fatal("expected highest offset (watermark) to be 10")
571 }
572 }
573
574 batch.Close()
575}
576
577func testConnReadBatchWithNoMinMaxBytes(t *testing.T, conn *Conn) {
578 if _, err := conn.WriteMessages(makeTestSequence(10)...); err != nil {

Callers

nothing calls this directly

Calls 6

makeTestSequenceFunction · 0.85
ReadBatchMethod · 0.80
HighWaterMarkMethod · 0.80
WriteMessagesMethod · 0.45
ReadMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected