Пример #1
0
def bootstrap(name="MicroService", testing=False, *args, **kwargs):
    list_openapi = Util.load_oai("central-service_token-storage.yml")

    app = App(name, *args, **kwargs)

    opts = {
        "use_in_memory_on_failure": (os.getenv("use_inmemory_as_fallover",
                                               "False") == "True")
    }
    if testing:
        app.app.config.update({"TESTING": True})
        opts = {"use_in_memory_on_failure": True}

    CommonUtil.monkeypatch(app=app.app)

    ServerUtil.storage = Storage(**opts)

    for oai in list_openapi:
        app.add_api(
            oai,
            resolver=MultipleResourceResolver(
                "api", collection_endpoint_name="index"),
            validate_responses=True,
        )

    return app
Пример #2
0
def bootstrap(name="MicroService", testing=False, *args, **kwargs):
    list_openapi = Util.load_oai("central-service_research-manager.yml")

    app = App(name, *args, **kwargs)
    RDSUtil.monkeypatch("getDict", app=app.app)

    opts = {
        "use_in_memory_on_failure": (os.getenv("use_inmemory_as_fallover",
                                               "False") == "True")
    }
    if testing:
        app.app.config.update({"TESTING": True})
        opts = {"use_in_memory_on_failure": True}

    Singleton.ProjectService = ProjectService(**opts)

    for oai in list_openapi:
        app.add_api(
            oai,
            resolver=MultipleResourceResolver(
                "api", collection_endpoint_name="index"),
            validate_responses=True,
        )

    return app
Пример #3
0
def bootstrap(name="MicroService", *args, **kwargs):
    import os
    from connexion_plus import App, MultipleResourceResolver, Util

    from lib.TokenService import TokenService

    list_openapi = Util.load_oai("use-case_port.yml")

    if "testing" in kwargs:
        ServerUtil.tokenService = TokenService(kwargs["testing"])
        del kwargs["testing"]
    else:
        ServerUtil.tokenService = TokenService()

    app = App(name, *args, **kwargs)
    CommonUtil.monkeypatch(app=app.app)

    for oai in list_openapi:
        app.add_api(
            oai,
            resolver=MultipleResourceResolver(
                "api", collection_endpoint_name="index"),
            validate_responses=True,
        )

    return app
Пример #4
0
def bootstrap(name="MicroService", *args, **kwargs):
    list_openapi = Util.load_oai("use-case_exporter.yml")

    app = App(name, *args, **kwargs)

    for oai in list_openapi:
        app.add_api(
            oai,
            resolver=MultipleResourceResolver(
                "api", collection_endpoint_name="index"),
            validate_responses=True,
        )

    return app
Пример #5
0
def bootstrap(name="MicroService", *args, **kwargs):
    list_openapi = Util.load_oai(
        os.getenv("OPENAPI_MULTIPLE_FILES",
                  "../../layer2_use_cases/interface_port_file_storage.yml"))

    app = App(name, *args, **kwargs)

    for oai in list_openapi:
        # TODO: enable validator for response
        app.add_api(
            oai,
            resolver=MultipleResourceResolver(
                "api", collection_endpoint_name="index"),
            validate_responses=False,
        )

    return app
Пример #6
0
def bootstrap(name='MicroService'):
    log_level = logging.DEBUG
    logger = logging.getLogger('')
    logging.getLogger('').handlers = []
    logging.basicConfig(format='%(asctime)s %(message)s', level=log_level)

    config = jConfig(
        config={  # usually read from some yaml config
            'sampler': {
                'type': 'const',
                'param': 1,
            },
            'logging': True,
        },
        service_name=name,
        validate=True,
        metrics_factory=PrometheusMetricsFactory(namespace=name),
    )

    openapi_dict = load_yaml_file()

    app = App(name,
              use_tracer=config.initialize_tracer(),
              use_metric=True,
              use_optimizer=True,
              use_cors=True)
    app.add_api(openapi_dict, resolver=MultipleResourceResolver('api'))

    # set the WSGI application callable to allow using uWSGI:
    # uwsgi --http :8080 -w app

    # start "python Tutorial2.py" and open "http://localhost:8080/v1.0/"
    app.run(port=int(os.getenv("SERVER_PORT", 8080)))
Пример #7
0
def bootstrap(name="MicroService", *args, **kwargs):
    list_openapi = Util.load_oai(
        os.getenv("OPENAPI_MULTIPLE_FILES",
                  "../../layer2_use_cases/interface_port_metadata.yml"))

    osf_address = None
    if "address" in kwargs:
        osf_address = kwargs["address"]
        del kwargs["address"]

    app = App(name, *args, **kwargs)

    app.app.osf_address = osf_address

    for oai in list_openapi:
        app.add_api(
            oai,
            resolver=MultipleResourceResolver(
                "api", collection_endpoint_name="index"),
            validate_responses=True,
        )

    return app
Пример #8
0
from connexion_plus import App
from connexion.resolver import RestyResolver
from jaeger_client import Config as jConfig
from jaeger_client.metrics.prometheus import PrometheusMetricsFactory
import logging

config = jConfig(
        config={
            'logging': True,
        },
        # use this, if you want to track your tracing itself with prometheus
        metrics_factory = PrometheusMetricsFactory(namespace=__name__),
    )
jaeger_tracer = config.initialize_tracer()

app = App(__name__, use_tracer=jaeger_tracer, use_metric=True, use_logging_level=logging.DEBUG)
app.add_api('openapi.yaml', resolver=RestyResolver('api'))

app.run(port=8080, server='gevent')