fix(DOC-1940): clarify rpk topic consume keeps connection open#1612
fix(DOC-1940): clarify rpk topic consume keeps connection open#1612
Conversation
Add a note explaining that rpk topic consume runs indefinitely by default, waiting for new records. Documents how to exit: Ctrl+C, --num, or an end offset with --offset. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
✅ Deploy Preview for redpanda-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis pull request adds documentation to the rpk topic consume command page, clarifying its default behavior. The changes explain that the command maintains a persistent connection and waits indefinitely for new records unless interrupted or controlled by the Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@modules/reference/pages/rpk/rpk-topic/rpk-topic-consume.adoc`:
- Around line 10-14: The doc text for rpk topic consume should clarify the range
offset pattern and either replace or augment `-o start:end` with explicit,
documented examples and a note about `end`'s meaning in ranges: update the
sentence referencing `--offset`/`-o` to show a clear example like `-o :end`
(consume until current end) and/or `-o `@-1m`:end` (consume from one minute ago to
current end), and add a short parenthetical explaining that `end` inside a range
denotes the current end offset (different from using `end` alone); edit the
offset table and examples section to include this explicit `:end`/`@-1m:end`
pattern and the clarifying note so readers aren’t confused by the standalone
`end` meaning.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 47393d7b-97a3-4f2f-9010-2d4e19f43fda
📒 Files selected for processing (1)
modules/reference/pages/rpk/rpk-topic/rpk-topic-consume.adoc
| By default, `rpk topic consume` opens a persistent connection and waits | ||
| indefinitely for new records to arrive. It does not exit after consuming | ||
| existing records. To stop consuming, press `Ctrl+C`, or use `--num` to exit | ||
| after a fixed number of records, or specify an end offset with `--offset` | ||
| (for example, `-o start:end`). |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for offset examples using start:end pattern
rg -n "start:end" --type=adoc
# Search for other offset range examples without timestamps
rg -n "\\-o\s+(start|end|:[^@]|\d+:)" --type=adoc -A2 -B2Repository: redpanda-data/docs
Length of output: 119
🏁 Script executed:
#!/bin/bash
# Search for start:end pattern without type filter
rg "start:end" --glob="*.adoc"
# Also search for offset examples in AsciiDoc files
rg "\-o\s+" --glob="*.adoc" -A2 -B2 | head -100Repository: redpanda-data/docs
Length of output: 6857
🏁 Script executed:
#!/bin/bash
# Read the specific file to check offset documentation
wc -l modules/reference/pages/rpk/rpk-topic/rpk-topic-consume.adoc
# Read the offset table section mentioned (lines 120-137)
sed -n '120,137p' modules/reference/pages/rpk/rpk-topic/rpk-topic-consume.adoc
# Read the examples section (lines 173-178)
sed -n '173,180p' modules/reference/pages/rpk/rpk-topic/rpk-topic-consume.adocRepository: redpanda-data/docs
Length of output: 949
Consider using more explicit documented examples for the offset specification.
The example -o start:end is not explicitly documented in the offset table (lines 120-137) or examples section (lines 173-178). While end can be used as an ending offset in ranges (as shown by -o @-1m:end in the examples), the specific pattern start:end doesn't appear elsewhere in the documentation and lacks clear definition.
Use more explicit, documented alternatives such as -o :end (line 126: "Consume until the current end") or model after existing examples like -o @-1m:end. This improves clarity since the offset table shows end as a standalone type meaning "Consume from the end," which could confuse readers about its different meaning when used in range syntax.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@modules/reference/pages/rpk/rpk-topic/rpk-topic-consume.adoc` around lines 10
- 14, The doc text for rpk topic consume should clarify the range offset pattern
and either replace or augment `-o start:end` with explicit, documented examples
and a note about `end`'s meaning in ranges: update the sentence referencing
`--offset`/`-o` to show a clear example like `-o :end` (consume until current
end) and/or `-o `@-1m`:end` (consume from one minute ago to current end), and add
a short parenthetical explaining that `end` inside a range denotes the current
end offset (different from using `end` alone); edit the offset table and
examples section to include this explicit `:end`/`@-1m:end` pattern and the
clarifying note so readers aren’t confused by the standalone `end` meaning.
| indefinitely for new records to arrive. It does not exit after consuming | ||
| existing records. To stop consuming, press `Ctrl+C`, or use `--num` to exit | ||
| after a fixed number of records, or specify an end offset with `--offset` | ||
| (for example, `-o start:end`). |
There was a problem hiding this comment.
-o start:end
-o :end is enough.
There was a problem hiding this comment.
Good call — fixed to -o :end. Also took the opportunity to clean up a few other prose issues on the page (kbd macro for Ctrl+C, simplify the --format json sentence, fix a tense issue, and a grammatical error).
…c-consume-connection
- Change -o start:end example to -o :end per daisukebe review - Use kbd:[Ctrl+C] macro for keyboard shortcut - Simplify --format json description; remove vague "special format" - Fix "prints the number in as ASCII" -> "as ASCII" - Use present tense: "will have their values printed" -> "have" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
micheleRP
left a comment
There was a problem hiding this comment.
Review Summary
The core issue (DOC-1940)
DOC-1940 reports that AI tools (and users) don't realize rpk topic consume opens a persistent connection and waits indefinitely. The description says: "we noticed that some AI tools fail to realize that rpk topic consume opens a connection and stays waiting for new messages to arrive."
RPK automation impact
Like PR #1618, this file is an rpk reference page where the generator (gen-rpk-ascii.py) produces:
- The title and
:description:attribute - The opening description paragraph (from
rpk topic consume --helpoutput) - The
== Usagesection - The
== Flagstable
The sections below the flags table (Attributes, Text, Headers, Values, Offsets, Examples) are manual additions that survive regeneration because the generator doesn't produce them.
The problem: The new paragraph about persistent connection behavior is inserted in the description zone (between the intro paragraph and the include:: directive). This zone is overwritten by whatever rpk topic consume --help outputs. So this addition will be lost on the next rpk doc regeneration.
The two bug fixes ("in as ASCII" → "as ASCII" on line 85, and "will have their values printed" → "have their values printed" on line 106) are in the manual sections and will survive regeneration.
Recommendation
The core value of this PR — documenting that rpk topic consume waits indefinitely — should be placed somewhere that survives regeneration. Two options:
-
Move the new paragraph below the
== Flagstable (e.g., as a new== Behavioror== Connection behaviorsection before== Attributes). Manual sections after the flags table are not overwritten by the generator. This is the simplest fix that preserves the intent. -
Update the
rpk topic consume --helptext upstream in the Redpanda Go source so it includes the persistent-wait behavior in the command description itself, and then regenerate.
Style notes
The content is well-written. A few suggestions:
-
"opens a persistent connection" is imprecise for Kafka protocol semantics. Consider: "runs continuously, waiting for new records to arrive" — this describes the observable behavior without implying a specific connection model.
-
The three-clause "To stop consuming, press Ctrl+C, or use
--num... or specify an end offset..." is long. Split into two sentences:To stop consuming, press kbd:[Ctrl+C]. You can also use
--numto exit after a fixed number of records, or use--offset(for example,-o :end) to stop at a specific offset. -
The grammar fix on line 85 ("in as ASCII" → "as ASCII") and the tense fix on line 106 ("will have" → "have") are both correct and good catches.
…c-consume-connection
…flags table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Ran this through Claude: Does it address DOC-1940? ✅ Yes The new == Connection behavior section directly addresses the ticket — it explains --- The rpk docs are fully regenerated from rpk --help output by gen-rpk-ascii.py. The # If the file exists, delete it. with open(filename, "w", encoding="utf-8") as filetowrite: There is no overrides mechanism for rpk docs (unlike properties → The other editorial changes (rewording --format json, removing "in as ASCII", --- The content needs to be added to the rpk source code help text in the redpanda repo If upstreaming to rpk isn't feasible right now, this should at minimum be flagged // NOTE: The section below is manually maintained and must be re-added after each asked Claude how this can be done without impacting automated content: There is no overrides mechanism for rpk docs — it doesn't exist yet. Unlike So the options are: 1. Keep the PR as-is with a clear comment warning it will be overwritten on Given that the overrides pattern is already established for properties and My recommendation: request changes on the PR noting that directly editing a |
|
@JakeSCahill Curious to know why we don't have an overrides file for rpk like we do for props? |
Summary
rpk topic consumeclarifying that the command opens a persistent connection and waits indefinitely for new records by defaultCtrl+C,--num, or an end offset with--offsetResolves DOC-1940.
Test plan
🤖 Generated with Claude Code