Skip to content

Conversation

@swarna1101
Copy link
Collaborator

@swarna1101 swarna1101 commented Jan 27, 2026

Summary by CodeRabbit

  • New Features

    • Added a flag to disable publish deduplication, allowing identical messages to be sent.
  • Behavior Changes

    • Publish timestamps are applied conditionally: deduplication remains enabled by default; disabling dedup omits the timestamp so identical messages can be delivered.
  • Tests

    • End-to-end tests added to validate both dedup-enabled and dedup-disabled publish behaviors.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Adds a --no-dedup CLI flag and makes PublishRequest.Timestamp optional (*int64 with json:"timestamp,omitempty"), allowing the publish command to omit the timestamp to disable timestamp-based deduplication when requested.

Changes

Cohort / File(s) Summary
Publish CLI changes
cmd/publish.go
Added noDedup flag; changed PublishRequest.Timestamp from int64 to *int64 with json:"timestamp,omitempty"; conditional timestamp pointer used in HTTP publish path to omit timestamp when --no-dedup is set.
End-to-end tests
e2e/publish_test.go
Added tests for --no-dedup with two sub-tests validating behavior when timestamp is included vs omitted; parses JSON publish responses and manages per-test subscriber lifecycle.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as CLI (publish cmd)
  participant API as Publish API (HTTP)
  participant Broker as Broker / Deduper

  CLI->>API: POST /publish { topic, message, timestamp? }
  alt no-dedup == false
    note right of CLI: timestamp = UnixMilli()
  else no-dedup == true
    note right of CLI: timestamp omitted (nil)
  end
  API->>Broker: deliver(message, timestamp?)
  alt timestamp present
    Broker->>Broker: use timestamp for dedup check
    Broker-->>API: accepted (unique) / message_id
  else timestamp absent
    Broker->>Broker: treat as identical -> deduplicate based on content/other keys
    Broker-->>API: deduplicated / same message_id
  end
  API-->>CLI: JSON { status, message_id }
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I tuck time into a pointer, then leap,
A flag decides if echoes wake or sleep.
Omit the tick, or set the chime —
Twice the send, once the rhyme. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding a --no-dedup flag to the publish command. This is confirmed by the raw summary showing flag addition, conditional timestamp logic, and comprehensive test coverage for the feature.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@swarna1101 swarna1101 force-pushed the feature/add-no-dedup-flag branch from d26866e to 8987033 Compare January 27, 2026 13:17
Copy link
Contributor

@Walentalien Walentalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test for both true/false values
can we do that inprocess somehow ?

@swarna1101 swarna1101 linked an issue Jan 27, 2026 that may be closed by this pull request
Copy link
Contributor

@Walentalien Walentalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets just close this pr and issue
Unless there is a reason why not

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cmd/publish.go (1)

141-183: The --no-dedup flag is silently ignored when using --grpc.

The gRPC path doesn't use the noDedup flag, and based on the proto definition, PublishRequest has no Timestamp field for gRPC. Users specifying --grpc --no-dedup may expect the flag to take effect.

Consider either:

  1. Logging a warning when both flags are used, or
  2. Documenting in the --no-dedup help text that it only applies to HTTP
Option 1: Add a warning when both flags are used
 		if useGRPCPub {
+			if noDedup {
+				fmt.Fprintln(os.Stderr, "⚠️  Warning: --no-dedup has no effect with --grpc (gRPC does not use timestamp-based deduplication)")
+			}
 			// gRPC publish logic
Option 2: Update flag description
-	publishCmd.Flags().BoolVar(&noDedup, "no-dedup", false, "Omit timestamp to use MsgHash(topic, message) instead of MsgHashWithTimestamp. Allows same message to be sent once per session (useful for stress testing/benchmarking)")
+	publishCmd.Flags().BoolVar(&noDedup, "no-dedup", false, "HTTP only: Omit timestamp to use MsgHash(topic, message) instead of MsgHashWithTimestamp. Allows same message to be sent once per session (useful for stress testing/benchmarking)")

@swarna1101 swarna1101 closed this Jan 28, 2026
@swarna1101 swarna1101 deleted the feature/add-no-dedup-flag branch January 28, 2026 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --no-dedup Flag for Testing

3 participants