slimta.cloudstorage.aws¶
This module is available with the python-slimta[aws]
package extra.
This module defines the queue storage mechanism specific to the Amazon Web Services hosting service. It requires an account as well as the Simple Storage Service (S3) and optionally the Simple Queue Service (SQS) services.
For each queued message, the contents and metadata of the message are written to S3. Upon success, a reference to the S3 object is injected into SQS as a new message.
The SQS service is only necessary for alerting separate slimta processes that a new message has been queued. If reception and relaying are happening in the same process, SQS is unnecessary.
NOTE: This module uses the boto library to communicate with AWS. To avoid performance issues, you must use gevent monkey patching before using it!
from gevent import monkey; monkey.patch_all()
s3_conn = boto.connect_s3()
s3_bucket = s3_conn.get_bucket('slimta-queue')
s3 = SimpleStorageService(s3_bucket)
sqs_conn = boto.sqs.connect_to_region('us-west-2')
sqs_queue = sqs_conn.create_queue('slimta-queue')
sqs = SimpleQueueService(sqs_queue)
queue_storage = CloudStorage(s3, sqs)