Ejemplo n.º 1
0
    def make_container(service_cls, config, worker_ctx_cls=None):

        container_cls = get_container_cls(config)

        if worker_ctx_cls is not None:
            warnings.warn(
                "The constructor of `container_factory` has changed. "
                "The `worker_ctx_cls` kwarg is now deprecated. See CHANGES, "
                "Version 2.4.0 for more details.", DeprecationWarning)

        container = container_cls(service_cls, config, worker_ctx_cls)
        all_containers.append(container)
        return container
Ejemplo n.º 2
0
    def make_container(service_cls, config, worker_ctx_cls=None):

        container_cls = get_container_cls(config)

        if worker_ctx_cls is not None:
            warnings.warn(
                "The constructor of `container_factory` has changed. "
                "The `worker_ctx_cls` kwarg is now deprecated. See CHANGES, "
                "Version 2.4.0 for more details.", DeprecationWarning
            )

        container = container_cls(service_cls, config, worker_ctx_cls)
        all_containers.append(container)
        return container
Ejemplo n.º 3
0
    def __init__(self, config, container_cls=None):
        self.service_map = {}
        self.config = config

        if container_cls is not None:
            warnings.warn(
                "The constructor of `ServiceRunner` has changed. "
                "The `container_cls` kwarg is now deprecated. You can "
                "use a custom class by setting the `SERVICE_CONTAINER_CLS` "
                "config option to dotted a class path. This warning will be "
                "removed in version 2.6.0.", DeprecationWarning)
        else:
            container_cls = get_container_cls(config)

        self.container_cls = container_cls
Ejemplo n.º 4
0
    def __init__(self, config, container_cls=None):
        self.service_map = {}
        self.config = config

        if container_cls is not None:
            warnings.warn(
                "The constructor of `ServiceRunner` has changed. "
                "The `container_cls` kwarg is now deprecated. You can "
                "use a custom class by setting the `SERVICE_CONTAINER_CLS` "
                "config option to dotted a class path. This warning will be "
                "removed in version 2.6.0.", DeprecationWarning
            )
        else:
            container_cls = get_container_cls(config)

        self.container_cls = container_cls
def app_with_scout(nameko_config=None, scout_config=None):
    """
    Context manager that yields a fresh Nameko WSGI app with Scout configured.
    """
    if scout_config is None:
        scout_config = {}

    scout_config["core_agent_launch"] = False
    scout_config.setdefault("monitor", True)
    Config.set(**scout_config)

    class Service(object):
        name = "myservice"

        scout = ScoutReporter()

        @http("GET", "/")
        def home(self, request):
            return "Welcome home."

        @http("GET", "/crash/")
        def crash(self, request):
            raise ValueError("BØØM!")  # non-ASCII

    if nameko_config is None:
        nameko_config = {}
    # Container setup copied from Nameko's container_factory pytest fixture,
    # which we don't use - see pytest.ini
    container_cls = get_container_cls(nameko_config)
    container = container_cls(Service, nameko_config)
    try:
        container.start()

        # A bit of introspection to look inside the container and pull out the WSGI
        # app
        app = list(container.subextensions)[0].get_wsgi_app()

        # N.B. We're sidestepping the Nameko testing conventions
        # (https://docs.nameko.io/en/stable/testing.html) to make our tests more
        # uniform between frameworks

        yield app
    finally:
        container.kill()
        Config.reset_all()
Ejemplo n.º 6
0
    def make_container(service_cls, config):

        container_cls = get_container_cls(config)
        container = container_cls(service_cls, config)
        all_containers.append(container)
        return container
Ejemplo n.º 7
0
    def __init__(self, config):
        self.service_map = {}
        self.config = config

        self.container_cls = get_container_cls(config)
Ejemplo n.º 8
0
    def __init__(self, config):
        self.service_map = {}
        self.config = config

        self.container_cls = get_container_cls(config)
Ejemplo n.º 9
0
    def make_container(service_cls, config):

        container_cls = get_container_cls(config)
        container = container_cls(service_cls, config)
        all_containers.append(container)
        return container