Exemplo n.º 1
0
def test_blob_serializer():
    serializer = BlobMessageSerializer()
    serialized = serializer(
        EventMessage(api_name="my.api", event_name="my_event", id="123", kwargs={"field": "value"})
    )
    assert json.loads(serialized) == {
        "metadata": {"api_name": "my.api", "event_name": "my_event", "id": "123", "version": 1},
        "kwargs": {"field": "value"},
    }
Exemplo n.º 2
0
 def __init__(
     self,
     *,
     redis_pool=None,
     url=None,
     serializer=BlobMessageSerializer(),
     deserializer=BlobMessageDeserializer(ResultMessage),
     connection_parameters: Mapping = frozendict(maxsize=100),
     result_ttl=60,
     rpc_timeout=5,
 ):
     # NOTE: We use the blob message_serializer here, as the results come back as values in a list
     self.set_redis_pool(redis_pool, url, connection_parameters)
     self.serializer = serializer
     self.deserializer = deserializer
     self.result_ttl = result_ttl
     self.rpc_timeout = rpc_timeout
Exemplo n.º 3
0
 def __init__(
     self,
     *,
     redis_pool=None,
     url=None,
     serializer=BlobMessageSerializer(),
     deserializer=BlobMessageDeserializer(RpcMessage),
     connection_parameters: Mapping = frozendict(maxsize=100),
     batch_size=10,
     rpc_timeout=5,
     consumption_restart_delay=5,
 ):
     self.set_redis_pool(redis_pool, url, connection_parameters)
     self._latest_ids = {}
     self.serializer = serializer
     self.deserializer = deserializer
     self.batch_size = batch_size
     self.rpc_timeout = rpc_timeout
     self.consumption_restart_delay = consumption_restart_delay