Skip to content
Snippets Groups Projects
Commit 837883bd authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

use Micronaut arg for basin url

parent f8b63ce0
No related branches found
No related tags found
1 merge request!503Docker and Web Services
......@@ -11,7 +11,6 @@ import gov.usgs.earthquake.nshmp.www.services.DeaggEpsilonService;
import gov.usgs.earthquake.nshmp.www.services.DeaggEpsilonService.Query;
import gov.usgs.earthquake.nshmp.www.services.HazardService;
import io.micronaut.context.event.StartupEvent;
import io.micronaut.http.HttpRequest;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.MediaType;
......@@ -19,7 +18,6 @@ import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.annotation.PathVariable;
import io.micronaut.http.annotation.QueryValue;
import io.micronaut.runtime.event.annotation.EventListener;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
......@@ -32,11 +30,6 @@ public class DeaggEpsilonController {
@Inject
private NshmpMicronautServlet servlet;
@EventListener
public void init(StartupEvent event) {
DeaggEpsilonService.init();
}
@Get(uri = "/usage", produces = MediaType.APPLICATION_JSON)
public HttpResponse<String> doGetUsage(HttpRequest<?> request) {
var urlHelper = servlet.urlHelper(request);
......
package gov.usgs.earthquake.nshmp.www.services;
import static com.google.common.base.Preconditions.checkNotNull;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.EnumMap;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.function.Function;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableList;
import com.google.common.io.Resources;
import gov.usgs.earthquake.nshmp.calc.CalcConfig;
import gov.usgs.earthquake.nshmp.calc.Deaggregation;
......@@ -30,6 +24,7 @@ import gov.usgs.earthquake.nshmp.www.meta.Metadata;
import gov.usgs.earthquake.nshmp.www.services.ServicesUtil.Key;
import gov.usgs.earthquake.nshmp.www.services.SourceServices.SourceModel;
import io.micronaut.context.annotation.Value;
import io.micronaut.http.HttpRequest;
import io.micronaut.http.HttpResponse;
......@@ -43,26 +38,9 @@ public final class DeaggEpsilonService {
/* Developer notes: See HazardService. */
private static final String NAME = "Epsilon Deaggregation";
private static URL basinUrl;
public static void init() {
try (InputStream config = Resources.getResource("config.properties").openStream()) {
checkNotNull(config, "Missing config.properties");
Properties props = new Properties();
props.load(config);
if (props.containsKey("basin_host")) {
/*
* TODO Site builder tests if service is working, which may be
* inefficient for single call services.
*/
var url = new URL(props.getProperty("basin_host") + "/nshmp/ws/data/basin");
basinUrl = url;
}
} catch (IOException | NullPointerException e) {
throw new RuntimeException(e);
}
}
@Value("${nshmp-haz.basin-service-url}")
private static URL basinUrl;
/**
* Handler for {@link DeaggEpsilonController#doGetDeaggEpsilon}. Returns the
......
......@@ -15,6 +15,12 @@ micronaut:
mapping: /**
nshmp-haz:
##
# The basin service url
# To specify the url to use:
# java -jar build/libs/nshmp-haz-v2.jar --basin-url=
basin-service-url: ${basin-service-url:https://staging-earthquake.usgs.gov/nshmp/ws/data/basin}
##
# The path to the models.
# To specify the model to use:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment