[][src]Struct sqsquatch::SubFut

pub struct SubFut { /* fields omitted */ }

Create futures that will intract with an SQS queue in a subscribe manner

Methods

impl SubFut[src]

pub fn initialize<T>(region: Region, queue_name: T) -> Result<Self> where
    T: Into<String>, 
[src]

Initialize SubFut

The following sources are checked in order for AWS credentials when calling initialize:

  1. Environment variables: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
  2. credential_process command in the AWS config file, usually located at ~/.aws/config.
  3. AWS credentials file. Usually located at ~/.aws/credentials.
  4. IAM instance profile. Will only work if running on an EC2 instance with an instance profile/role.

If the sources are exhausted without finding credentials, an error is returned.

See the documentation for DefaultCredentialsProvider and ChainProvider for more information.

Example

let subscriber = SubFut::initialize(Region::UsEast2, "Orders")?;

pub fn receive_message_fut(
    &mut self,
    message_attribute_names: Option<Vec<String>>,
    visibility_timeout: Option<i64>,
    wait_time_seconds: Option<i64>
) -> impl Future<Item = ReceiveMessageResult, Error = Error>
[src]

Create a future that will receive a message from the queue.

  • visibility_timeout - the duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a receive_message request.
  • wait_time_seconds - The duration (in seconds) for which the call waits for a message to arrive in the queue before returning. If a message is available, the call returns sooner than wait_time_seconds. If no messages are available and the wait time expires, the call returns successfully with an empty list of messages.

Example

// subscriber initialized as above..
let result = subscriber.receive_message_fut(None, Some(30), Some(20)).compat().await?;
assert!(result.messages.is_some());

if let Some(messages) = result.messages {
    assert_eq!(messages.len(), 1);
    assert!(messages[0].receipt_handle.is_some());

    if let Some(receipt_handle) = &messages[0].receipt_handle {
        assert_eq!(receipt_handle, "MbZj6wDWli+JvwwJaBV+3dcjk2YW2vA3+STFFljTM8tJJg6HRG6PYSasuWXPJB+CwLj1FjgXUv1uSj1gUPAWV66FU/WeR4mq2OKpEGYWbnLmpRCJVAyeMjeU5ZBdtcQ+QEauMZc8ZRv37sIW2iJKq3M9MFx1YvV11A2x/KSbkJ0=");
    }
}

pub fn delete_message_fut(
    &mut self,
    receipt_handle: String
) -> impl Future<Item = (), Error = Error>
[src]

Delete a message from the queue.

  • receipt_handle - The receipt handle associated with the message to delete. NOTE this is not the message id. It's a unique identifier on a per-receive request.

Example

// subscriber initialized as above..
let _ = subscriber.delete_message_fut("a receipt_handle".to_string()).compat().await?;

Trait Implementations

impl Clone for SubFut[src]

impl Debug for SubFut[src]

Auto Trait Implementations

impl Send for SubFut

impl Sync for SubFut

impl Unpin for SubFut

impl !UnwindSafe for SubFut

impl !RefUnwindSafe for SubFut

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self