Exemplo n.º 1
0
def default_inventory(monkeypatch):
    samples_dir = os.path.abspath(
        os.path.join(os.path.dirname(__file__), "..", "samples"))
    monkeypatch.setenv(*env_var("SERVICELIB_INVENTORY_CLASS", "default"))
    monkeypatch.setenv(*env_var("SERVICELIB_WORKER_SERVICES_DIR", samples_dir))
    monkeypatch.syspath_prepend(samples_dir)
    return inventory.instance()
Exemplo n.º 2
0
def test_invalid_inventory_factory(monkeypatch):
    monkeypatch.setenv(*env_var("SERVICELIB_INVENTORY_CLASS", "no-such-impl"))
    with pytest.raises(Exception) as exc:
        inventory.instance()
    assert str(
        exc.value) == "Invalid value for `inventory.class`: no-such-impl"
Exemplo n.º 3
0
import falcon

from servicelib import config, inventory, logutils
from servicelib.falcon import HealthResource, StatsResource, WorkerResource

__all__ = [
    "application",
]

# On y va!

logutils.configure_logging(
    level=config.get("log_level", default="debug").upper(),
    log_type=config.get("log_type", default="text"),
)

services = inventory.instance().load_services()

application = falcon.API(media_type=falcon.MEDIA_JSON)
application.add_route("/services/{service}", WorkerResource(services))

# Now that routes for services have been set up, we are ready to
# handle requests. Let Kubernetes know (or whoever may be sending
# health check probes) by enabling the health check route.
application.add_route("/health", HealthResource())

application.add_route("/stats", StatsResource())

os.umask(0o22)