def test_sns_queue_route_keep_message_translator(dummy_handler): route = SNSQueueRoute("what", handler=dummy_handler, message_translator=SQSMessageTranslator()) assert isinstance(route.message_translator, SQSMessageTranslator) route = SNSQueueRoute("what", handler=dummy_handler, message_translator=None) assert route.message_translator is None
def test_sns_queue_route_provider_options(dummy_handler): route = SNSQueueRoute("what", provider_options={"region_name": "sa-east-1"}, handler=dummy_handler, name="foobar") assert "region_name" in route.provider._client_options assert route.provider._client_options["region_name"] == "sa-east-1"
def test_sns_queue_route_provider_options(dummy_handler): route = SNSQueueRoute('what', provider_options={'region_name': 'sa-east-1'}, handler=dummy_handler, name='foobar') assert 'region_name' in route.provider._client_options assert route.provider._client_options['region_name'] == 'sa-east-1'
from loafer.ext.aws.routes import SNSQueueRoute from .config import settings from .handlers import envia_multa_handler provider_options = { "endpoint_url": settings.AWS_ENDPOINT_URL, "options": { "MaxNumberOfMessages": 10, "WaitTimeSeconds": 1 }, } routes = (SNSQueueRoute( settings.MULTA_CRIADA_FILA, provider_options=provider_options, handler=envia_multa_handler, ), )
from loafer.ext.aws.routes import SNSQueueRoute from .config import settings from .handlers import PlayerHandler, TeamHandler, error_handler provider_options = { "endpoint_url": settings.AWS_ENDPOINT_URL, "options": { "MaxNumberOfMessages": 10, "WaitTimeSeconds": settings.WAIT_TIME_SECONDS }, } routes = ( SNSQueueRoute( settings.TEAMS_MATCH_CREATED_QUEUE, provider_options=provider_options, handler=TeamHandler(), error_handler=error_handler, ), SNSQueueRoute( settings.PLAYERS_MATCH_CREATED_QUEUE, provider_options=provider_options, handler=PlayerHandler(), error_handler=error_handler, ), )
# Third from loafer.ext.aws.routes import SNSQueueRoute # Local from .handlers import CreateCustomerHandler routes = [ SNSQueueRoute( name='route1', provider_queue='iugu-customers-main-prd', provider_options={'endpoint': 'localhost:4100'}, handler=CreateCustomerHandler(), ) ]
def test_sns_queue_route_keep_name(dummy_handler): route = SNSQueueRoute("what", handler=dummy_handler, name="foobar") assert route.name == "foobar"
def test_sns_queue_route(dummy_handler): route = SNSQueueRoute("what", handler=dummy_handler) assert isinstance(route.message_translator, SNSMessageTranslator) assert isinstance(route.provider, SQSProvider) assert route.name == "what"
import os from loafer.ext.aws.routes import SNSQueueRoute from loafer.managers import LoaferManager async def echo_message_handler(message, *args): print(f"message is {message}") print(f"args is {args}") await asyncio.sleep(0.5) return True async def error_handler(exc_type, message): print(f"exception {exc_type} received") return False endpoint_url = os.environ.get("AWS_ENDPOINT_URL", "http://localhost:4100") routes = (SNSQueueRoute( "echo__loafer__notification", provider_options={"endpoint_url": endpoint_url}, handler=echo_message_handler, error_handler=error_handler, ), ) manager = LoaferManager(routes=routes) manager.run(debug=True)
def test_sns_queue_route_keep_name(dummy_handler): route = SNSQueueRoute('what', handler=dummy_handler, name='foobar') assert route.name == 'foobar'
from loafer.ext.aws.routes import SNSQueueRoute from .handlers import FoobarFriendCreatedHandler routes = (SNSQueueRoute( provider_queue='foobar-friend-created', provider_options={ 'endpoint_url': 'http://localhost:4100', }, handler=FoobarFriendCreatedHandler(), ), )
from loafer.ext.aws.routes import SNSQueueRoute from goat_tweet_analyzer.handlers import ProcessTweetsHandler from goat_tweet_analyzer.config import settings from goat_tweet_analyzer.translators import GoatMessagesTranslator provider_options = { "endpoint_url": settings.AWS_ENDPOINT_URL, "options": { "MaxNumberOfMessages": 10, "WaitTimeSeconds": int(settings.WAIT_TIME_SECONDS) }, } routes = (SNSQueueRoute( provider_queue=settings.TWEET_QUEUE, provider_options=provider_options, handler=ProcessTweetsHandler(), message_translator=GoatMessagesTranslator(), ), )