def _enqueue_message(self, message: ff.Message, context: str = None):
     memory = None
     if hasattr(message, '_memory'):
         memory = getattr(message, '_memory')
     queue = self._sqs_resource.get_queue_by_name(
         QueueName=self._queue_name(context or message.get_context(), memory=memory)
     )
     queue.send_message(MessageBody=self._store_large_payloads_in_s3(
         self._serializer.serialize(message),
         name=message.__class__.__name__,
         type_='command' if isinstance(message, ff.Command) else 'event',
         context=message.get_context(),
         id_=getattr(message, '_id', str(uuid.uuid4()))
     ))
Example #2
0
 def mw(message: Message, next_: Callable):
     context, cmd = str(command).split('.')
     ret = next_(message)
     if message.get_context(
     ) == context and message.__class__.__name__ == cmd:
         if hasattr(ret, 'then'):
             return ret.then(lambda _: self.refresh())
     return ret
    def handle(self, message: ff.Message) -> Optional[bool]:
        if hasattr(message, 'fail_authentication'):
            raise ff.UnauthenticatedError()

        if hasattr(message, 'scopes'):
            message.headers['decoded_token'] = {
                'scopes': json.loads(message.scopes),
            }
        return True
 def create_response(self, request: ff.Message):
     return self._server.create_authorization_response(
         request.headers.get('uri'), request.headers.get('http_method'),
         request.to_dict(), request.headers)
Example #5
0
 def mw(message: Message, next_: Callable):
     context, cmd = str(command).split('.')
     if message.get_context(
     ) == context and message.__class__.__name__ == cmd:
         self._stream(handler(message, self._stream()))
     return next_(message)
 def _get_template(self, message: Message):
     request = message.headers['http_request']
     return self._environments[message.get_context()]\
         .get_template(f"{request['path']}.{request['method'].lower()}.html")
Example #7
0
def sut():
    return Message()
Example #8
0
 def __call__(self, message: Message, next_: Callable, *args, **kwargs):
     if 'numbers' not in message.headers:
         message.headers['numbers'] = []
     message.headers['numbers'].append(self.number)
     return next_(message)