Skip to content

Adding initialVisibilityDelay option to Azure Storage Queue binding #3820

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

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

Conversation

willvelida
Copy link
Contributor

@willvelida willvelida commented May 17, 2025

Description

This PR implements the initialVisibilityDelay option for Azure Queue Storage Binding. This feature allows setting a delay before a message becomes visible in the queue after being added, which is a functionality available in the Azure Storage Queue service.

The implementation includes:

  1. Adding the InitialVisibilityDelay field to the storageQueuesMetadata struct with appropriate mapstructure tags
  2. Modifying the QueueHelper interface to include the initialVisibilityDelay parameter in the Write method
  3. Updating the AzureQueueHelper.Write implementation to use the initialVisibilityDelay parameter when calling EnqueueMessage
  4. Adding logic in the AzureStorageQueues.Invoke method to extract initialVisibilityDelay from request metadata
  5. Adding documentation in metadata.yaml for the new option
  6. Creating tests to verify the functionality:
    • Added a specific unit test TestWriteWithInitialVisibilityDelay that verifies the initialVisibilityDelay parameter is correctly passed from the request metadata to the Write method
    • Updated the mock helper to support the new initialVisibilityDelay parameter
    • Modified existing tests to accommodate the new parameter, ensuring backward compatibility
    • Verified that the functionality works properly by asserting that the value passed to EnqueueMessage matches the expected value

Issue reference

This PR will close #3555

Checklist

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

@willvelida willvelida requested review from a team as code owners May 17, 2025 09:22
@@ -54,7 +55,7 @@ type consumer struct {
// QueueHelper enables injection for testnig.
type QueueHelper interface {
Init(ctx context.Context, metadata bindings.Metadata) (*storageQueuesMetadata, error)
Write(ctx context.Context, data []byte, ttl *time.Duration) error
Write(ctx context.Context, data []byte, ttl *time.Duration, initialVisibilityDelay *time.Duration) error
Copy link
Contributor

Choose a reason for hiding this comment

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

If this value is passed as a parameter but isn't expected to change dynamically, I suggest making it a struct property in the types that implement this interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After setting the default value to 0, I was thinking that if we keep it as a parameter, consumers can configure it on a per-message basis and it keep some consistency with the ttl parameter. I'm also think that using a struct here could introduce race conditions with the binding.

@willvelida willvelida requested a review from nelson-parente May 26, 2025 11:29
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.

Azure Queue: InitialVisibilityDelay option
2 participants