如果设置了上下文超时,则无法从主题中读取消息-segmentio/kafka go reader

如果设置了上下文超时,则无法从主题中读取消息-segmentio/kafka go reader,go,kafka-consumer-api,go-testing,Go,Kafka Consumer Api,Go Testing,我有一个Kafka ConsumerGroup(Golang/Segmentio),其中一个阅读器是单元测试用例的一部分 r := kafka.NewReader(kafka.ReaderConfig{ Brokers: []string{"localhost:9092"}, Topic: "test", CommitInterval: time.Second, // flus

我有一个Kafka ConsumerGroup(Golang/Segmentio),其中一个阅读器是单元测试用例的一部分

r := kafka.NewReader(kafka.ReaderConfig{
        Brokers:        []string{"localhost:9092"},
        Topic:          "test",
        CommitInterval: time.Second, // flushes commits to Kafka every second
        MaxWait:        10 * time.Millisecond,
        GroupID:        "test_logs",
        StartOffset:    kafka.LastOffset,
    })
读卡器能够读取消息,但在读取主题中的所有消息后,它正在等待新消息,测试用例在30秒后超时

如果我设置
context.WithTimeout(ctx,20*time.Second)
,则读者无法读取主题中的任何消息

因此,我如何阅读主题中的消息并继续,而不是等待新消息