Пример #1
0
"""Transport registry."""
from typing import Iterator, Type

from mode.utils.imports import FactoryMapping

from faust.types import AppT, FixupT

__all__ = ["by_name", "by_url", "fixups"]

FIXUPS: FactoryMapping[Type[FixupT]] = FactoryMapping(
    django="faust.fixups.django:Fixup", )
FIXUPS.include_setuptools_namespace("faust.fixups")
by_name = FIXUPS.by_name
by_url = FIXUPS.by_url


def fixups(app: AppT) -> Iterator[FixupT]:
    """Iterate over enabled fixups.

    Fixups are installed by setuptools, using the 'faust.fixups'
    namespace.

    Fixups modify the Faust library to work with frameworks
    such as Django.
    """
    for Fixup in FIXUPS.iterate():
        fixup = Fixup(app)
        if fixup.enabled():
            yield fixup
Пример #2
0
"""Transport registry."""
from typing import Type
from mode.utils.imports import FactoryMapping
from faust.types import TransportT

__all__ = ['by_name', 'by_url']

TRANSPORTS: FactoryMapping[Type[TransportT]] = FactoryMapping(
    aiokafka='faust.transport.drivers.aiokafka:Transport',
    kafka='faust.transport.drivers.aiokafka:Transport',
    memory='faust.transport.drivers.memory:Transport',
)
TRANSPORTS.include_setuptools_namespace('faust.transports')
by_name = TRANSPORTS.by_name
by_url = TRANSPORTS.by_url
Пример #3
0
"""Web server driver registry."""
from typing import Type

from mode.utils.imports import FactoryMapping

from faust.web.base import Web

__all__ = ["by_name", "by_url"]

DRIVERS: FactoryMapping[Type[Web]] = FactoryMapping(
    aiohttp="faust.web.drivers.aiohttp:Web", )
DRIVERS.include_setuptools_namespace("faust.web.drivers")
by_name = DRIVERS.by_name
by_url = DRIVERS.by_url
Пример #4
0
"""Cache backend registry."""
from typing import Type

from mode.utils.imports import FactoryMapping

from faust.types.web import CacheBackendT

__all__ = ["by_name", "by_url"]

BACKENDS: FactoryMapping[Type[CacheBackendT]] = FactoryMapping(
    memory="faust.web.cache.backends.memory:CacheBackend",
    redis="faust.web.cache.backends.redis:CacheBackend",
    rediscluster="faust.web.cache.backends.redis:CacheBackend",
)
BACKENDS.include_setuptools_namespace("faust.web.cache")
by_name = BACKENDS.by_name
by_url = BACKENDS.by_url
Пример #5
0
 def map(self):
     return FactoryMapping({
         'redis': 'my.drivers.RedisDriver',
         'rabbitmq': 'my.drivers.RabbitDriver',
     })
Пример #6
0
"""Storage registry."""
from typing import Type

from mode.utils.imports import FactoryMapping

from faust.types import StoreT

__all__ = ["by_name", "by_url"]

STORES: FactoryMapping[Type[StoreT]] = FactoryMapping(
    memory="faust.stores.memory:Store",
    rocksdb="faust.stores.rocksdb:Store",
    aerospike="faust.stores.aerospike:AeroSpikeStore",
)
STORES.include_setuptools_namespace("faust.stores")
by_name = STORES.by_name
by_url = STORES.by_url
Пример #7
0
 def map(self):
     return FactoryMapping({
         "redis": "my.drivers.RedisDriver",
         "rabbitmq": "my.drivers.RabbitDriver",
     })
Пример #8
0
"""Storage registry."""
from typing import Type

from mode.utils.imports import FactoryMapping

from faust.types import StoreT

__all__ = ["by_name", "by_url"]

STORES: FactoryMapping[Type[StoreT]] = FactoryMapping(
    memory="faust.stores.memory:Store",
    rocksdb="faust.stores.rocksdb:Store",
)
STORES.include_setuptools_namespace("faust.stores")
by_name = STORES.by_name
by_url = STORES.by_url
Пример #9
0
"""Transport registry."""
from typing import Type
from mode.utils.imports import FactoryMapping
from faust.types import TransportT

__all__ = ['by_name', 'by_url']

TRANSPORTS: FactoryMapping[Type[TransportT]] = FactoryMapping(
    aiokafka='faust.transport.drivers.aiokafka:Transport',
    confluent='faust.transport.drivers.confluent:Transport',
    kafka='faust.transport.drivers.aiokafka:Transport',
)
TRANSPORTS.include_setuptools_namespace('faust.transports')
by_name = TRANSPORTS.by_name
by_url = TRANSPORTS.by_url