mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-01 09:08:11 +08:00
Allow SQS to use environment variables
This commit is contained in:
@@ -51,9 +51,12 @@ class Sqs(Broker):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_connection(list_key=Conf.PREFIX):
|
def get_connection(list_key=Conf.PREFIX):
|
||||||
return Session(aws_access_key_id=Conf.SQS['aws_access_key_id'],
|
config = Conf.SQS
|
||||||
aws_secret_access_key=Conf.SQS['aws_secret_access_key'],
|
if 'aws_region' in config:
|
||||||
region_name=Conf.SQS['aws_region'])
|
config['region_name'] = config['aws_region']
|
||||||
|
del(config['aws_region'])
|
||||||
|
return Session(**config)
|
||||||
|
|
||||||
|
|
||||||
def get_queue(self):
|
def get_queue(self):
|
||||||
self.sqs = self.connection.resource('sqs')
|
self.sqs = self.connection.resource('sqs')
|
||||||
|
|||||||
+4
-4
@@ -229,7 +229,7 @@ All connection keywords are supported. See the `iron-mq <https://github.com/iron
|
|||||||
|
|
||||||
sqs
|
sqs
|
||||||
~~~
|
~~~
|
||||||
To use Amazon SQS as a broker you need to provide the AWS region and credentials::
|
To use Amazon SQS as a broker you need to provide the AWS region and credentials either via the config, or any other boto3 configuration method::
|
||||||
|
|
||||||
# example SQS broker connection
|
# example SQS broker connection
|
||||||
|
|
||||||
@@ -241,9 +241,9 @@ To use Amazon SQS as a broker you need to provide the AWS region and credentials
|
|||||||
'queue_limit': 100,
|
'queue_limit': 100,
|
||||||
'bulk': 5,
|
'bulk': 5,
|
||||||
'sqs': {
|
'sqs': {
|
||||||
'aws_region': 'us-east-1',
|
'aws_region': 'us-east-1', # optional
|
||||||
'aws_access_key_id': 'ac-Idr.....YwflZBaaxI',
|
'aws_access_key_id': 'ac-Idr.....YwflZBaaxI', # optional
|
||||||
'aws_secret_access_key': '500f7b....b0f302e9'
|
'aws_secret_access_key': '500f7b....b0f302e9' # optional
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user