From c8199d2679d7ce91a44f6b64fc417e6e300acc00 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Mon, 22 Apr 2024 13:02:49 -0600 Subject: [PATCH] add priming --- .../earthquake/nshmp/www/PrimingResource.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/gov/usgs/earthquake/nshmp/www/PrimingResource.java diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/PrimingResource.java b/src/main/java/gov/usgs/earthquake/nshmp/www/PrimingResource.java new file mode 100644 index 00000000..fcf7707b --- /dev/null +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/PrimingResource.java @@ -0,0 +1,42 @@ +package gov.usgs.earthquake.nshmp.www; + +import java.util.logging.Logger; + +import org.crac.Context; +import org.crac.Resource; + +import com.amazonaws.serverless.proxy.internal.testutils.MockLambdaContext; +import com.amazonaws.serverless.proxy.model.AwsProxyRequest; + +import io.micronaut.context.annotation.Value; +import io.micronaut.crac.OrderedResource; +import io.micronaut.function.aws.proxy.MicronautLambdaHandler; +import jakarta.inject.Singleton; + +/** + * Prime application for AWS Lambda snapstart. + */ +@Singleton +public class PrimingResource implements OrderedResource { + + @Value("${nshmp.context-path}") + String contextPath; + + @Override + public void beforeCheckpoint(Context<? extends Resource> context) throws Exception { + Logger log = Logger.getAnonymousLogger(); + + log.info("Before checkpoint"); + } + + @Override + public void afterRestore(Context<? extends Resource> context) throws Exception {} + + private static AwsProxyRequest getAwsProxyRequest(String path) { + + final AwsProxyRequest awsProxyRequest = new AwsProxyRequest(); + awsProxyRequest.setHttpMethod("GET"); + awsProxyRequest.setPath(path); + return awsProxyRequest; + } +} -- GitLab