Search in sources :

Example 1 with WebRequestDiagnostics

use of org.folio.inventory.common.WebRequestDiagnostics in project mod-inventory by folio-org.

the class InventoryVerticle method start.

@Override
public void start(Promise<Void> started) {
    Logging.initialiseFormat();
    final Logger log = LogManager.getLogger(MethodHandles.lookup().lookupClass());
    Router router = Router.router(vertx);
    server = vertx.createHttpServer();
    JsonObject config = vertx.getOrCreateContext().config();
    log.info("Received Config");
    config.fieldNames().forEach(key -> log.info(String.format("%s:%s", key, config.getValue(key).toString())));
    HttpClient client = vertx.createHttpClient();
    Storage storage = Storage.basedUpon(vertx, config, client);
    new IngestMessageProcessor(storage).register(vertx.eventBus());
    router.route().handler(WebRequestDiagnostics::outputDiagnostics);
    new ModsIngestion(storage, client).register(router);
    new Items(storage, client).register(router);
    new MoveApi(storage, client).register(router);
    new Instances(storage, client).register(router);
    new Holdings(storage).register(router);
    new InstancesBatch(storage, client).register(router);
    new IsbnUtilsApi().register(router);
    new ItemsByHoldingsRecordId(storage, client).register(router);
    new InventoryConfigApi().register(router);
    new TenantApi().register(router);
    Handler<AsyncResult<HttpServer>> onHttpServerStart = result -> {
        if (result.succeeded()) {
            log.info(String.format("Listening on %s", server.actualPort()));
            started.complete();
        } else {
            started.fail(result.cause());
        }
    };
    server.requestHandler(router).listen(config.getInteger("port"), onHttpServerStart);
}
Also used : WebRequestDiagnostics(org.folio.inventory.common.WebRequestDiagnostics) PostgresClientFactory(org.folio.inventory.common.dao.PostgresClientFactory) HttpServer(io.vertx.core.http.HttpServer) Router(io.vertx.ext.web.Router) InstancesBatch(org.folio.inventory.resources.InstancesBatch) TenantApi(org.folio.inventory.resources.TenantApi) Instances(org.folio.inventory.resources.Instances) IsbnUtilsApi(org.folio.inventory.resources.IsbnUtilsApi) Holdings(org.folio.inventory.resources.Holdings) Items(org.folio.inventory.resources.Items) JsonObject(io.vertx.core.json.JsonObject) ModsIngestion(org.folio.inventory.resources.ingest.ModsIngestion) AsyncResult(io.vertx.core.AsyncResult) MoveApi(org.folio.inventory.resources.MoveApi) Promise(io.vertx.core.Promise) MethodHandles(java.lang.invoke.MethodHandles) ItemsByHoldingsRecordId(org.folio.inventory.resources.ItemsByHoldingsRecordId) InventoryConfigApi(org.folio.inventory.resources.InventoryConfigApi) Storage(org.folio.inventory.storage.Storage) Logger(org.apache.logging.log4j.Logger) AbstractVerticle(io.vertx.core.AbstractVerticle) IngestMessageProcessor(org.folio.inventory.domain.ingest.IngestMessageProcessor) Handler(io.vertx.core.Handler) LogManager(org.apache.logging.log4j.LogManager) HttpClient(io.vertx.core.http.HttpClient) Router(io.vertx.ext.web.Router) JsonObject(io.vertx.core.json.JsonObject) ItemsByHoldingsRecordId(org.folio.inventory.resources.ItemsByHoldingsRecordId) WebRequestDiagnostics(org.folio.inventory.common.WebRequestDiagnostics) IsbnUtilsApi(org.folio.inventory.resources.IsbnUtilsApi) Logger(org.apache.logging.log4j.Logger) IngestMessageProcessor(org.folio.inventory.domain.ingest.IngestMessageProcessor) Instances(org.folio.inventory.resources.Instances) InstancesBatch(org.folio.inventory.resources.InstancesBatch) TenantApi(org.folio.inventory.resources.TenantApi) Storage(org.folio.inventory.storage.Storage) Holdings(org.folio.inventory.resources.Holdings) HttpClient(io.vertx.core.http.HttpClient) Items(org.folio.inventory.resources.Items) ModsIngestion(org.folio.inventory.resources.ingest.ModsIngestion) AsyncResult(io.vertx.core.AsyncResult) MoveApi(org.folio.inventory.resources.MoveApi) InventoryConfigApi(org.folio.inventory.resources.InventoryConfigApi)

Example 2 with WebRequestDiagnostics

use of org.folio.inventory.common.WebRequestDiagnostics in project mod-inventory by folio-org.

the class FailureInventoryStorageModule method start.

@Override
public void start(Promise deployed) {
    server = vertx.createHttpServer();
    Router router = Router.router(vertx);
    server.requestHandler(router).listen(PORT_TO_USE, result -> {
        if (result.succeeded()) {
            System.out.printf("Starting failing storage module listening on %s%n", server.actualPort());
            deployed.complete();
        } else {
            deployed.fail(result.cause());
        }
    });
    router.route().handler(WebRequestDiagnostics::outputDiagnostics);
    router.route("/server-error/item-storage/items*").handler(this::serverError);
    router.route("/server-error/instance-storage/instances*").handler(this::serverError);
    router.route("/server-error/authority-storage/authorities*").handler(this::serverError);
    router.route("/bad-request/item-storage/items*").handler(this::badRequest);
    router.route("/bad-request/instance-storage/instances*").handler(this::badRequest);
    router.route("/bad-request/instance-storage/instances*").handler(this::badRequest);
    router.route("/bad-request/authority-storage/authorities*").handler(this::badRequest);
}
Also used : Router(io.vertx.ext.web.Router) WebRequestDiagnostics(org.folio.inventory.common.WebRequestDiagnostics)

Aggregations

Router (io.vertx.ext.web.Router)2 WebRequestDiagnostics (org.folio.inventory.common.WebRequestDiagnostics)2 AbstractVerticle (io.vertx.core.AbstractVerticle)1 AsyncResult (io.vertx.core.AsyncResult)1 Handler (io.vertx.core.Handler)1 Promise (io.vertx.core.Promise)1 HttpClient (io.vertx.core.http.HttpClient)1 HttpServer (io.vertx.core.http.HttpServer)1 JsonObject (io.vertx.core.json.JsonObject)1 MethodHandles (java.lang.invoke.MethodHandles)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 PostgresClientFactory (org.folio.inventory.common.dao.PostgresClientFactory)1 IngestMessageProcessor (org.folio.inventory.domain.ingest.IngestMessageProcessor)1 Holdings (org.folio.inventory.resources.Holdings)1 Instances (org.folio.inventory.resources.Instances)1 InstancesBatch (org.folio.inventory.resources.InstancesBatch)1 InventoryConfigApi (org.folio.inventory.resources.InventoryConfigApi)1 IsbnUtilsApi (org.folio.inventory.resources.IsbnUtilsApi)1 Items (org.folio.inventory.resources.Items)1