The current behavior of the Reader is to retry OffsetOutOfRange errors indefinitely, which results in programs hanging in the event of a topic being re-created while a consumer is running. To retain backwards-compatibility, ReaderConfig.OffsetOutOfRangeError is being used to instruct the Reader to r
(t *testing.T, ctx context.Context, r *Reader)
| 1977 | // ReaderConfig.OffsetOutOfRangeError is being used to instruct the Reader to |
| 1978 | // return an error in this case instead, allowing callers to react. |
| 1979 | func testReaderTopicRecreated(t *testing.T, ctx context.Context, r *Reader) { |
| 1980 | r.config.OffsetOutOfRangeError = true |
| 1981 | |
| 1982 | topic := r.config.Topic |
| 1983 | |
| 1984 | // add 1 message to the topic |
| 1985 | prepareReader(t, ctx, r, makeTestSequence(1)...) |
| 1986 | |
| 1987 | // consume the message (moving the offset from 0 -> 1) |
| 1988 | _, err := r.ReadMessage(ctx) |
| 1989 | require.NoError(t, err) |
| 1990 | |
| 1991 | // destroy the topic, then recreate it so the offset now becomes 0 |
| 1992 | deleteTopic(t, topic) |
| 1993 | createTopic(t, topic, 1) |
| 1994 | |
| 1995 | // expect an error, since the offset should now be out of range |
| 1996 | _, err = r.ReadMessage(ctx) |
| 1997 | require.ErrorIs(t, err, OffsetOutOfRange) |
| 1998 | } |
nothing calls this directly
no test coverage detected