slimta.diskstorage

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

Package implementing the queue storage system on disk. Disk reads and writes are built using the aio interface, provided in python by the pyaio project.

class slimta.diskstorage.DiskStorage(env_dir, meta_dir[, tmp_dir=None])

Bases: slimta.queue.QueueStorage

QueueStorage mechanism that stores Envelope and queue metadata in two separate files on disk.

Parameters:
  • env_dir – Directory where queue envelope files are stored. These files may be large and will not be modified after initial writing.
  • meta_dir – Directory where queue meta files are stored. These files will be small and volatile.
  • tmp_dir – Directory that may be used as scratch space. New files are written here and then moved to their final destination. System temp directories are used by default.
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