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

Add configurable ackDeadline to GCP Pub/Sub component #3422

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mahparaashley
Copy link

@mahparaashley mahparaashley commented May 21, 2024

Description

(ackDeadline) for the GCP Pub/Sub component within Dapr's components-contrib repository. Previously, the acknowledgment deadline was hardcoded to 20 seconds. This change allows users to specify a custom acknowledgment deadline through the component's metadata, thus providing greater flexibility to tailor behavior to specific workload requirements.

Motivation

In many scenarios, the hardcoded 20-second deadline may not be optimal. Applications with varying processing times may require longer deadlines to prevent premature message redelivery, which can lead to increased costs and workload on services. Making this value configurable allows users to optimize their systems based on actual performance and needs.

Changes

Metadata Structure: Added an AckDeadline field to the metadata struct to hold the user-defined acknowledgment deadline.
Default Value: Set a default acknowledgment deadline (defaultAckDeadline) to 20 seconds to maintain backward compatibility.
Metadata Parsing: Updated the createMetadata function to parse the ackDeadline from the component's metadata, with validation to ensure it is a positive integer.
Subscription Configuration: Modified the subscription configuration logic in the ensureSubscription method to utilize the user-configured ackDeadline.
Testing: Enhanced the test suite to include tests for validating the behavior with a specified ackDeadline, handling of invalid values, and default behavior when not specified.

Testing

Comprehensive tests were added to validate:

The correct parsing and application of a valid ackDeadline.
Proper error handling when an invalid ackDeadline is provided.
The use of the default ackDeadline when none is specified.
These tests ensure that the new functionality behaves as expected and that existing functionalities remain unaffected.

Impact

This change is backward compatible. Existing configurations without a specified ackDeadline will use the default value, ensuring that current implementations will operate without modifications. New users can specify an ackDeadline to suit their specific needs.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[issue number]
#3421

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation / Created issue in the https://github.com/dapr/docs/ repo: dapr/docs#[issue number]

Copy link
Contributor

@ItalyPaleAle ItalyPaleAle left a comment

Choose a reason for hiding this comment

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

pubsub/gcp/pubsub/pubsub.go Outdated Show resolved Hide resolved
Signed-off-by: mashley@rechargeapps.com <mashley@rechargeapps.com>
@mahparaashley mahparaashley force-pushed the improve-ack-deadline-flexibility branch from 063057d to 3637c71 Compare May 21, 2024 20:32
Updated the AckDeadline field in the metadata struct to use time.Duration instead of int. This change allows Dapr to interpret the acknowledgment deadline as either seconds or Go duration strings, providing greater flexibility and usability for configuring message acknowledgment timeouts.

Signed-off-by: mashley@rechargeapps.com <mashley@rechargeapps.com>
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.

None yet

4 participants