Skip to content

feature: add ackwait config #190

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

shellphy
Copy link

@shellphy shellphy commented Jan 20, 2025

Reason for This PR

Avoid duplication of tasks

Description of Changes

This is a simpler implementation of #189.

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

    • Added configuration option for acknowledgment wait time in NATS jobs driver
    • Enhanced consumer configuration with more granular message acknowledgment settings
  • Improvements

    • Introduced AckWait parameter to provide more control over message processing timeouts

Copy link

coderabbitai bot commented Jan 20, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces an AckWait configuration parameter to the NATS jobs package, allowing more precise control over message acknowledgment wait times. The changes span three files in the natsjobs package, adding a new time.Duration field to the configuration, driver, and listener components. This enhancement provides more flexibility in managing message acknowledgment timeouts across the NATS job processing system.

Changes

File Change Summary
natsjobs/config.go Added AckWait time.Duration field with mapstructure:"ack_wait" tag; Updated InitDefaults to set default 30s value
natsjobs/driver.go Added ackWait time.Duration field to Driver struct; Initialized in FromConfig and FromPipeline methods
natsjobs/listener.go Updated consumer configuration to include AckWait parameter from c.ackWait

Sequence Diagram

sequenceDiagram
    participant Config as Configuration
    participant Driver as NATS Job Driver
    participant Listener as Message Listener
    
    Config->>Driver: Set AckWait Duration
    Driver->>Listener: Configure Consumer AckWait
    Listener-->>Driver: Apply Acknowledgment Timeout
Loading

Poem

🐰 A Rabbit's Ode to Acknowledgment Delight

With AckWait's grace, messages take flight,
Thirty seconds to ponder, to hold just right,
NATS jobs dancing with temporal might,
Configuration's whisper, a technical 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@rustatian
Copy link
Member

Hey @shellphy 👋🏻
Thank you for the PR 👍🏻

I'm not sure, you just added a configuration option and skip using it anywhere?

@rustatian rustatian added the enhancement New feature or request label Jan 21, 2025
@rustatian rustatian marked this pull request as draft January 21, 2025 20:42
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: 2

🧹 Nitpick comments (2)
natsjobs/config.go (1)

34-34: Add documentation for the AckWait field.

Please add a comment explaining the purpose and expected format of the AckWait configuration field.

+       // AckWait is the duration the server should wait for an ack before resending a message
        AckWait            time.Duration `mapstructure:"ack_wait"`
natsjobs/driver.go (1)

52-55: Improve field grouping in Driver struct.

Consider grouping related fields together for better readability. The NATS-related fields should be grouped together.

        // nats
        consumer     *consumer
        consumerLock sync.RWMutex
        conn         *nats.Conn
-
-       stream    jetstream.Stream
-       jetstream jetstream.JetStream
-       msgCh     chan jetstream.Msg
+       stream     jetstream.Stream
+       jetstream  jetstream.JetStream
+       msgCh      chan jetstream.Msg
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7355284 and 0b2b92f.

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

22-22: LGTM!

The AckWait configuration is correctly integrated into the NATS JetStream consumer configuration.

@shellphy
Copy link
Author

@shellphy👋🏻 谢谢你的 PR 👍🏻

我不确定,您只是添加了一个配置选项并跳过在任何地方使用它?

listener.go:

cons, err := c.jetstream.CreateConsumer(ctx, c.streamID, jetstream.ConsumerConfig{
		Name:          id,
		MaxAckPending: c.prefetch,
		AckPolicy:     jetstream.AckExplicitPolicy,
		AckWait:       c.ackWait,
	})

@rustatian
Copy link
Member

@shellphy Could you please also update documentation?

@rustatian rustatian changed the title add ackwait config feature: add ackwait config Jan 23, 2025
@rustatian
Copy link
Member

@shellphy PHP part: https://github.com/roadrunner-php/jobs/blob/4.x/src/Queue/NatsCreateInfo.php should be synced as well (ack_wait constant).

@rustatian
Copy link
Member

Hey @shellphy 👋🏻
LGTM, but the last piece is missing - PR into roadrunner-php/jobs package.

@rustatian
Copy link
Member

@shellphy Friendly ping, do you have plans to continue working on this PR?

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
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

2 participants