Пример #1
0
 async def _new_bus():
     bus = await lightbus.creation.create_async(
         config=RootConfig(
             apis={
                 'default': ApiConfig(
                     rpc_transport=RpcTransportSelector(
                         redis=RedisRpcTransport.Config(url=redis_server_url)
                     ),
                     result_transport=ResultTransportSelector(
                         redis=RedisResultTransport.Config(url=redis_server_url)
                     ),
                     event_transport=EventTransportSelector(redis=RedisEventTransport.Config(
                         url=redis_server_url,
                         stream_use=StreamUse.PER_EVENT,
                         service_name="test_service",
                         consumer_name="test_consumer",
                     )),
                 )
             },
             bus=BusConfig(
                 schema=SchemaConfig(
                     transport=SchemaTransportSelector(redis=RedisSchemaTransport.Config(url=redis_server_url)),
                 )
             )
         ),
         plugins=[],
     )
     return bus
Пример #2
0
def dummy_bus(loop, redis_server_url):
    # fmt: off
    dummy_bus = lightbus.creation.create(
        config=RootConfig(
            apis={
                'default':
                ApiConfig(
                    rpc_transport=RpcTransportSelector(
                        debug=DebugRpcTransport.Config()),
                    result_transport=ResultTransportSelector(
                        debug=DebugResultTransport.Config()),
                    event_transport=EventTransportSelector(
                        debug=DebugEventTransport.Config()),
                )
            },
            bus=BusConfig(
                schema=SchemaConfig(transport=SchemaTransportSelector(
                    redis=RedisSchemaTransport.Config(
                        url=redis_server_url)), ))),
        plugins=[],
    )
    # fmt: on
    yield dummy_bus
    try:
        dummy_bus.client.close()
    except BusAlreadyClosed:
        pass
Пример #3
0
 def _new_bus(service_name="{friendly}"):
     bus = lightbus.creation.create(
         config=RootConfig(
             apis={
                 'default':
                 ApiConfig(
                     rpc_transport=RpcTransportSelector(
                         redis=RedisRpcTransport.Config(
                             url=redis_server_url)),
                     result_transport=ResultTransportSelector(
                         redis=RedisResultTransport.Config(
                             url=redis_server_url)),
                     event_transport=EventTransportSelector(
                         redis=RedisEventTransport.Config(
                             url=redis_server_url,
                             stream_use=StreamUse.PER_EVENT,
                             service_name="test_service",
                             consumer_name="test_consumer",
                         )),
                 )
             },
             bus=BusConfig(
                 schema=SchemaConfig(transport=SchemaTransportSelector(
                     redis=RedisSchemaTransport.Config(
                         url=redis_server_url)), )),
             service_name=service_name),
         plugins=[],
     )
     bus.client.disable_proxy()
     return bus