slimta.cloudstorage

This module is available in the python-slimta-cloudstorage extension package.

Package containing a module for the different cloud service providers along with any necessary helper modules.

exception slimta.cloudstorage.CloudStorageError([*args[, **kwargs]])

Bases: slimta.queue.QueueError

Base exception for all exceptions in the package.

class slimta.cloudstorage.CloudStorage(object_store[, message_queue=None])

Bases: slimta.queue.QueueStorage

This class implements a QueueStorage backend that uses cloud services to store messages. It coordinates the storage of messages and metadata (using Cloud Files or S3) with the optional message queue mechanisms (using Cloud Queues or SQS) that can alert other slimta processes that a new message is available in the object store.

Parameters:
  • object_store – The object used as the backend for storing message contents and metadata in the cloud. Currently this can be an instance of RackspaceCloudFiles or SimpleStorageService.
  • message_queue – The optional object used as the backend for alerting other processes that a new message is in the object store. Currently this can be an instance of RackspaceCloudQueues or SimpleQueueService.
write(envelope, timestamp)

Writes the given envelope to storage, along with the timestamp of its next delivery attempt. The number of delivery attempts asociated with the message should start at zero.

Parameters:
  • envelopeEnvelope object to write.
  • timestamp – Timestamp of message’s next delivery attempt.
Returns:

Unique identifier string for the message in queue.

Raises:

QueueError

set_timestamp(id, timestamp)

Sets a new timestamp for the message’s next delivery attempt.

Parameters:
  • id – The unique identifier string for the message.
  • timestamp – The new delivery attempt timestamp.
Raises:

QueueError

increment_attempts(id)

Increments the number of delivery attempts associated with the message.

Parameters:id – The unique identifier string for the message.
Returns:The new number of message delivery attempts.
Raises:QueueError
set_recipients_delivered(id, rcpt_indexes)

New in version 1.1.0.

Marks the given recipients from the original envelope as already-delivered, meaning they will be skipped by future relay attempts.

Parameters:
  • id – The unique identifier string for the message.
  • rcpt_indexes – List of indexes in the original envelope’s recipients list to mark as delivered.
Raises:

QueueError

load()

Loads all queued messages from the storage engine, such that the Queue can be aware of all upcoming delivery attempts.

Returns:Iterable that yields tuples of the form (timestamp, id) for each message in storage.
Raises:QueueError
get(id)

Returns the Envelope object associated with the given unique identifier sring.

The envelope’s recipients should not include those marked as delivered by set_recipients_delivered().

Parameters:id – The unique identifier string of the requested Envelope.
Returns:Tuple with the Envelope object and number of attempts.
Raises:KeyError, QueueError
remove(id)

Removes the Envelope associated with the given unique identifier string from queue storage. This is typically used when the message has been successfully delivered or delivery has permanently failed.

Parameters:id – The unique identifier string of the Envelope to remove.
Raises:QueueError
wait()

If messages are not being delivered from the same process in which they were received, the storage mechanism needs a way to wait until it is notified that a new message has been stored.

Returns:An iterable or generator producing tuples with the timestamp and unique identifier string of a new message in storage. When the iterable or generator is exhausted, wait() is simply called again.

Sub-Modules: