feature: add ackwait config#190
Conversation
WalkthroughAdds an AckWait time.Duration configuration to natsjobs, propagating it from config -> driver -> listener and setting a default of 30s when unspecified. Changes
Sequence Diagram(s)sequenceDiagram
participant Config as Configuration
participant Driver as NATS Driver
participant Listener as Consumer
Note over Config: default AckWait = 30s if unset
Config->>Driver: provide AckWait (time.Duration)
Driver->>Listener: pass ackWait when creating consumer
Listener->>Listener: set ConsumerConfig.AckWait = ackWait
Listener-->>Driver: consumer created with AckWait
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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 |
|
Hey @shellphy 👋🏻 I'm not sure, you just added a configuration option and skip using it anywhere? |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
go.work.sumis 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.
listener.go: cons, err := c.jetstream.CreateConsumer(ctx, c.streamID, jetstream.ConsumerConfig{
Name: id,
MaxAckPending: c.prefetch,
AckPolicy: jetstream.AckExplicitPolicy,
AckWait: c.ackWait,
}) |
|
@shellphy Could you please also update documentation? |
|
@shellphy PHP part: https://github.com/roadrunner-php/jobs/blob/4.x/src/Queue/NatsCreateInfo.php should be synced as well (ack_wait constant). |
|
Hey @shellphy 👋🏻 |
|
@shellphy Friendly ping, do you have plans to continue working on this PR? |
91ce843 to
75fcaa9
Compare
|
It can be merged. |
|
Thank you @shellphy 👍🏻 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #190 +/- ##
=============================
=============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@shellphy, I've assigned your PR to the PHP devs (I don't know PHP) on the PHP client library side. |
|
You may ping them as well 😃 |
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]git commit -s).CHANGELOG.md.Summary by CodeRabbit
New Features
Improvements