Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: publisher confirms #169

Merged
merged 3 commits into from
Nov 10, 2024
Merged

feature: publisher confirms #169

merged 3 commits into from
Nov 10, 2024

Conversation

rustatian
Copy link
Member

@rustatian rustatian commented Nov 8, 2024

Reason for This PR

  • use publisher confirms by default

Description of Changes

  • Use publisher confirms on every push by default. PC can fail with context timeout error or with basic.ack was false.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the MIT license.

PR Checklist

[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]

  • All commits in this PR are signed (git commit -s).
  • The reason for this PR is clearly provided (issue no. or explanation).
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • Any user-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.

Summary by CodeRabbit

  • New Features

    • Enhanced message publishing reliability with deferred confirmation handling.
  • Bug Fixes

    • Improved error handling for message publishing failures.
  • Chores

    • Updated multiple dependencies to their latest versions for improved compatibility and performance.

Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
@rustatian rustatian added the enhancement New feature or request label Nov 8, 2024
@rustatian rustatian requested a review from wolfy-j November 8, 2024 22:43
@rustatian rustatian self-assigned this Nov 8, 2024
Copy link

coderabbitai bot commented Nov 8, 2024

Warning

Rate limit exceeded

@rustatian has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 11 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 326ae7d and afa6dbd.

Walkthrough

The changes in this pull request primarily involve significant updates to the amqpjobs package, specifically enhancing the message publishing method in the Driver struct to use a deferred confirmation approach. This modification includes improved error handling for message publishing failures. Additionally, both the go.mod and tests/go.mod files have been updated to reflect the latest versions of various dependencies, including OpenTelemetry and gRPC, ensuring compatibility and incorporating potential improvements.

Changes

File Change Summary
amqpjobs/driver.go Updated handleItem method to use PublishWithDeferredConfirmWithContext, added confirmation check and error handling.
go.mod Updated multiple dependencies, including OpenTelemetry and golang.org/x/sys, to their latest versions.
tests/go.mod Updated dependencies in the tests module, including grpc-gateway, OpenTelemetry, and various indirect dependencies.

Poem

In the burrow where the code does play,
A hop and a skip, new changes today!
With messages confirmed, no more to fear,
The rabbit hops high, spreading good cheer!
Dependencies fresh, all shiny and bright,
Coding adventures, oh what a delight! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 32e1026 and 7e69b4b.

⛔ Files ignored due to path filters (3)
  • go.sum is excluded by !**/*.sum
  • go.work.sum is excluded by !**/*.sum
  • tests/go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • amqpjobs/driver.go (1 hunks)
  • go.mod (2 hunks)
  • tests/go.mod (2 hunks)
🔇 Additional comments (5)
go.mod (2)

17-20: LGTM! Consistent OpenTelemetry package updates.

The OpenTelemetry packages have been consistently updated from v1.31.0 to v1.32.0, maintaining version alignment across all related dependencies.

Also applies to: 37-37


17-22: Verify compatibility with the updated dependencies.

While these are minor version updates and should be backward compatible, it's important to ensure they don't introduce any breaking changes, especially given the focus on AMQP publisher confirms in this PR.

Also applies to: 37-37

✅ Verification successful

Let me check the specific usage of these dependencies to better understand their impact.


Let me check one more aspect - the specific OpenTelemetry API usage patterns to ensure there are no deprecated or changed APIs being used.


Dependencies update appears safe to proceed

The analysis shows standard and stable OpenTelemetry API usage patterns:

  • Basic tracer provider and span operations
  • Standard propagation APIs (TextMapPropagator, TraceContext, Baggage)
  • Common global configuration patterns
  • The sys package is only used for CPU feature detection in TLS configuration

The code uses well-established, stable APIs that are unlikely to have breaking changes in minor version updates. The AMQP publisher confirms functionality is independent of these dependencies.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any compatibility issues or breaking changes in the updated dependencies

# Test 1: Check if there are any direct uses of potentially changed OpenTelemetry APIs
echo "Checking OpenTelemetry API usage..."
rg -l "go.opentelemetry.io/(otel|contrib)" --type go

# Test 2: Look for any sys package usage that might be affected
echo "Checking sys package usage..."
rg -l "golang.org/x/sys" --type go

Length of output: 305


Script:

#!/bin/bash
# Check OpenTelemetry usage patterns
echo "=== OpenTelemetry Usage in plugin.go ==="
rg "go.opentelemetry.io/(otel|contrib)" plugin.go -B 2 -A 2

echo -e "\n=== OpenTelemetry Usage in amqpjobs/driver.go ==="
rg "go.opentelemetry.io/(otel|contrib)" amqpjobs/driver.go -B 2 -A 2

echo -e "\n=== OpenTelemetry Usage in amqpjobs/listener.go ==="
rg "go.opentelemetry.io/(otel|contrib)" amqpjobs/listener.go -B 2 -A 2

echo -e "\n=== sys Package Usage in amqpjobs/tls.go ==="
rg "golang.org/x/sys" amqpjobs/tls.go -B 2 -A 2

Length of output: 1336


Script:

#!/bin/bash
# Check specific OpenTelemetry API usage patterns
echo "=== Checking trace API usage ==="
rg "trace\." --type go -B 2 -A 2

echo -e "\n=== Checking propagation API usage ==="
rg "propagation\." --type go -B 2 -A 2

echo -e "\n=== Checking otel global API usage ==="
rg "otel\." --type go -B 2 -A 2

Length of output: 6558

tests/go.mod (3)

102-109: Standard library and Google API updates look appropriate.

The updates to golang.org/x/* packages and Google APIs are routine maintenance changes that bring in the latest improvements and security fixes. These changes are compatible with Go 1.23.2 as specified in the toolchain directive.


46-46: Core dependency updates require compatibility verification.

The updates to key dependencies:

  • gRPC Gateway (v2.23.0)
  • Temporal API (v1.41.0)
  • gRPC (v1.68.0)

These updates are significant and may affect the RPC communication layer used by the AMQP publisher confirms feature.

#!/bin/bash
# Description: Check for potential breaking changes in RPC layer
# Test: Search for gRPC and Temporal API usage patterns that might need updates
rg "grpc\." -A 3
rg "temporal\." -A 3

Also applies to: 98-98, 110-110


86-96: OpenTelemetry updates align with publisher confirms implementation.

The comprehensive update of OpenTelemetry components to v1.32.0 is beneficial for monitoring and observability of the new publisher confirms feature. This version includes improvements in tracing and metrics collection.

✅ Verification successful

Let me gather more information about OpenTelemetry usage in the codebase.


Let me check the actual OpenTelemetry implementation details to verify its usage.


OpenTelemetry dependency updates are properly integrated and utilized

The OpenTelemetry updates to v1.32.0 are well-justified as the codebase actively uses OpenTelemetry for tracing:

  • Proper integration in amqpjobs/driver.go with trace propagation and SDK usage
  • Test environment configured with collector, Zipkin, and Jaeger support
  • Active usage in the codebase through the otel plugin
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify OpenTelemetry usage in the codebase
# Test: Search for OpenTelemetry instrumentation to ensure it's properly utilized
rg -l "go.opentelemetry.io/otel"

Length of output: 2138


Script:

#!/bin/bash
# Search for OpenTelemetry imports and usage
rg -l "opentelemetry"

# Search specifically for otel instrumentation patterns
ast-grep --pattern 'otel.$_'

Length of output: 236


Script:

#!/bin/bash
# Check OpenTelemetry implementation details
rg -A 5 "opentelemetry" plugin.go
rg -A 5 "opentelemetry" amqpjobs/driver.go amqpjobs/listener.go
cat tests/env/docker-compose-amqp.yaml

Length of output: 2128

Comment on lines +717 to +725
// if error is not nil, ok would be false
if err != nil {
return errors.E(op, fmt.Errorf("failed to get publisher confirm: %w", err))
}

// publish was unsuccessful
if !ok {
return errors.E(op, fmt.Errorf("failed to get publisher confirm"))
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Correct the misleading comment and refine error handling

The comment on line 717 is misleading. If err is not nil, it indicates a communication error or context cancellation, not necessarily that ok would be false.

Additionally, when err is nil but ok is false, it means the broker negatively acknowledged the message (Nack). The error handling should reflect this distinction to provide clearer diagnostics.

Apply this diff to correct the comment and refine the error handling:

-		// if error is not nil, ok would be false
-		if err != nil {
-			return errors.E(op, fmt.Errorf("failed to get publisher confirm: %w", err))
-		}
-
-		// publish was unsuccessful
-		if !ok {
-			return errors.E(op, fmt.Errorf("failed to get publisher confirm"))
-		}
+		if err != nil {
+			// Communication error or context timeout
+			return errors.E(op, fmt.Errorf("failed to receive publisher confirm: %w", err))
+		}
+
+		if !ok {
+			// The broker negatively acknowledged the message
+			return errors.E(op, errors.Str("message was negatively acknowledged by the broker"))
+		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// if error is not nil, ok would be false
if err != nil {
return errors.E(op, fmt.Errorf("failed to get publisher confirm: %w", err))
}
// publish was unsuccessful
if !ok {
return errors.E(op, fmt.Errorf("failed to get publisher confirm"))
}
if err != nil {
// Communication error or context timeout
return errors.E(op, fmt.Errorf("failed to receive publisher confirm: %w", err))
}
if !ok {
// The broker negatively acknowledged the message
return errors.E(op, errors.Str("message was negatively acknowledged by the broker"))
}

Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
@rustatian rustatian changed the title feature: publiser confirms feature: publisher confirms Nov 9, 2024
@rustatian rustatian merged commit de0cd8f into master Nov 10, 2024
9 checks passed
@rustatian rustatian deleted the feature/pub-confirms branch November 10, 2024 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant