-
Notifications
You must be signed in to change notification settings - Fork 290
move storage queues to pipeline architecture #851
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,5 @@ | ||||||||||||
use crate::prelude::*; | ||||||||||||
use crate::requests::*; | ||||||||||||
use crate::{operations::*, prelude::*}; | ||||||||||||
use azure_core::{Context, Request, Response}; | ||||||||||||
use azure_storage::core::clients::StorageClient; | ||||||||||||
use std::sync::Arc; | ||||||||||||
|
||||||||||||
|
@@ -39,6 +39,14 @@ impl PopReceiptClient { | |||||||||||
}) | ||||||||||||
} | ||||||||||||
|
||||||||||||
pub(crate) async fn send( | ||||||||||||
&self, | ||||||||||||
context: &mut Context, | ||||||||||||
request: &mut Request, | ||||||||||||
) -> azure_core::Result<Response> { | ||||||||||||
self.queue_client.send(context, request).await | ||||||||||||
} | ||||||||||||
|
||||||||||||
pub(crate) fn storage_client(&self) -> &StorageClient { | ||||||||||||
self.queue_client.storage_client() | ||||||||||||
} | ||||||||||||
|
@@ -56,16 +64,19 @@ impl PopReceiptClient { | |||||||||||
Ok(url) | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// Deletes the message. The message must not have been | ||||||||||||
/// made visible again or this call would fail. | ||||||||||||
/// Deletes the message. The message must not have been made visible again | ||||||||||||
/// or this call would fail. | ||||||||||||
pub fn delete(&self) -> DeleteMessageBuilder { | ||||||||||||
DeleteMessageBuilder::new(self) | ||||||||||||
DeleteMessageBuilder::new(self.clone()) | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// Updates the message. | ||||||||||||
/// The message must not have been | ||||||||||||
/// made visible again or this call would fail. | ||||||||||||
pub fn update(&self, visibility_timeout: impl Into<VisibilityTimeout>) -> UpdateMessageBuilder { | ||||||||||||
UpdateMessageBuilder::new(self, visibility_timeout) | ||||||||||||
/// Updates the message. The message must not have been made visible again | ||||||||||||
/// or this call would fail. | ||||||||||||
Comment on lines
+73
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Also, it might be nice to place this above |
||||||||||||
pub fn update( | ||||||||||||
&self, | ||||||||||||
body: impl Into<String>, | ||||||||||||
visibility_timeout: impl Into<VisibilityTimeout>, | ||||||||||||
) -> UpdateMessageBuilder { | ||||||||||||
UpdateMessageBuilder::new(self.clone(), body.into(), visibility_timeout.into()) | ||||||||||||
} | ||||||||||||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,8 +1,13 @@ | ||||||||||||
use crate::requests::*; | ||||||||||||
use azure_core::error::{ErrorKind, ResultExt}; | ||||||||||||
use azure_storage::core::clients::{AsStorageClient, StorageAccountClient, StorageClient}; | ||||||||||||
use std::fmt::Debug; | ||||||||||||
use std::sync::Arc; | ||||||||||||
use crate::{operations::*, QueueStoredAccessPolicy}; | ||||||||||||
use azure_core::{ | ||||||||||||
error::{ErrorKind, ResultExt}, | ||||||||||||
prelude::*, | ||||||||||||
Context, Request, Response, | ||||||||||||
}; | ||||||||||||
use azure_storage::core::clients::{ | ||||||||||||
AsStorageClient, ServiceType, StorageAccountClient, StorageClient, | ||||||||||||
}; | ||||||||||||
use std::{fmt::Debug, sync::Arc}; | ||||||||||||
|
||||||||||||
pub trait AsQueueClient<QN: Into<String>> { | ||||||||||||
fn queue_client(&self, queue_name: QN) -> Arc<QueueClient>; | ||||||||||||
|
@@ -34,6 +39,16 @@ impl QueueClient { | |||||||||||
}) | ||||||||||||
} | ||||||||||||
|
||||||||||||
pub(crate) async fn send( | ||||||||||||
&self, | ||||||||||||
context: &mut Context, | ||||||||||||
request: &mut Request, | ||||||||||||
) -> azure_core::Result<Response> { | ||||||||||||
self.storage_client | ||||||||||||
.send(context, request, ServiceType::Queue) | ||||||||||||
.await | ||||||||||||
} | ||||||||||||
|
||||||||||||
pub(crate) fn storage_client(&self) -> &StorageClient { | ||||||||||||
self.storage_client.as_ref() | ||||||||||||
} | ||||||||||||
|
@@ -53,68 +68,77 @@ impl QueueClient { | |||||||||||
|
||||||||||||
/// Creates the queue. | ||||||||||||
pub fn create(&self) -> CreateQueueBuilder { | ||||||||||||
CreateQueueBuilder::new(self) | ||||||||||||
CreateQueueBuilder::new(self.clone()) | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// Deletes the queue. | ||||||||||||
pub fn delete(&self) -> DeleteQueueBuilder { | ||||||||||||
DeleteQueueBuilder::new(self) | ||||||||||||
DeleteQueueBuilder::new(self.clone()) | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// Sets or clears the queue metadata. The metadata | ||||||||||||
/// will be passed to the `execute` function of the returned struct. | ||||||||||||
pub fn set_metadata(&self) -> SetQueueMetadataBuilder { | ||||||||||||
SetQueueMetadataBuilder::new(self) | ||||||||||||
/// Sets or clears the queue metadata. | ||||||||||||
/// | ||||||||||||
/// Keep in mind that keys present on Azure but not included in the passed | ||||||||||||
/// metadata parameter will be deleted. If you want to keep the preexisting | ||||||||||||
/// key-value pairs, retrieve them with GetMetadata first and then | ||||||||||||
/// update/add to the received Metadata struct. Then pass the Metadata back | ||||||||||||
/// to SetQueueMetadata. If you just want to clear the metadata, just pass | ||||||||||||
/// an empty Metadata struct. | ||||||||||||
pub fn set_metadata(&self, metadata: Metadata) -> SetQueueMetadataBuilder { | ||||||||||||
SetQueueMetadataBuilder::new(self.clone(), metadata) | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// Get the queue metadata. | ||||||||||||
|
||||||||||||
pub fn get_metadata(&self) -> GetQueueMetadataBuilder { | ||||||||||||
GetQueueMetadataBuilder::new(self) | ||||||||||||
GetQueueMetadataBuilder::new(self.clone()) | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// Get the queue ACL. This call returns | ||||||||||||
/// all the stored access policies associated | ||||||||||||
/// to the current queue. | ||||||||||||
pub fn get_acl(&self) -> GetQueueACLBuilder { | ||||||||||||
GetQueueACLBuilder::new(self) | ||||||||||||
GetQueueACLBuilder::new(self.clone()) | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// Set the queue ACL. You can call this function | ||||||||||||
/// to change or remove already existing stored | ||||||||||||
/// access policies by modifying the list returned | ||||||||||||
/// Set the queue ACL. You can call this function to change or remove | ||||||||||||
/// already existing stored access policies by modifying the list returned | ||||||||||||
/// by `get_acl`. | ||||||||||||
pub fn set_acl(&self) -> SetQueueACLBuilder { | ||||||||||||
SetQueueACLBuilder::new(self) | ||||||||||||
/// | ||||||||||||
/// While this SDK does not enforce any limit, keep in mind Azure supports a | ||||||||||||
/// limited number of stored access policies for each queue. More info here | ||||||||||||
/// [https://docs.microsoft.com/rest/api/storageservices/set-queue-acl#remarks](https://docs.microsoft.com/rest/api/storageservices/set-queue-acl#remarks). | ||||||||||||
pub fn set_acl(&self, policies: Vec<QueueStoredAccessPolicy>) -> SetQueueACLBuilder { | ||||||||||||
SetQueueACLBuilder::new(self.clone(), policies) | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// Puts a message in the queue. The body will be passed | ||||||||||||
/// to the `execute` function of the returned struct. | ||||||||||||
Comment on lines
115
to
116
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
pub fn put_message(&self) -> PutMessageBuilder { | ||||||||||||
PutMessageBuilder::new(self) | ||||||||||||
pub fn put_message<S: Into<String>>(&self, message: S) -> PutMessageBuilder { | ||||||||||||
PutMessageBuilder::new(self.clone(), message.into()) | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// Peeks, without removing, one or more messages. | ||||||||||||
pub fn peek_messages(&self) -> PeekMessagesBuilder { | ||||||||||||
PeekMessagesBuilder::new(self) | ||||||||||||
PeekMessagesBuilder::new(self.clone()) | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// Gets, shadowing them, one or more messages. | ||||||||||||
pub fn get_messages(&self) -> GetMessagesBuilder { | ||||||||||||
GetMessagesBuilder::new(self) | ||||||||||||
GetMessagesBuilder::new(self.clone()) | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// Removes all messages from the queue. | ||||||||||||
pub fn clear_messages(&self) -> ClearMessagesBuilder { | ||||||||||||
ClearMessagesBuilder::new(self) | ||||||||||||
ClearMessagesBuilder::new(self.clone()) | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
#[cfg(test)] | ||||||||||||
#[cfg(feature = "test_integration")] | ||||||||||||
mod integration_tests { | ||||||||||||
use super::*; | ||||||||||||
use crate::core::prelude::*; | ||||||||||||
use crate::queue::clients::AsQueueClient; | ||||||||||||
use crate::{core::prelude::*, queue::clients::AsQueueClient}; | ||||||||||||
|
||||||||||||
fn get_emulator_client(queue_name: &str) -> Arc<QueueClient> { | ||||||||||||
let storage_account = StorageAccountClient::new_emulator_default().storage_client(); | ||||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.