Skip to content

Commit

Permalink
[ALL][OPS] Bump versions, add missing Lambda handler util
Browse files Browse the repository at this point in the history
  • Loading branch information
MamishIo committed Feb 18, 2022
1 parent 34427f8 commit a292c16
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
7 changes: 4 additions & 3 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ env:
shell: bash
variables:
CDK_VERSION: "1.130.0"
GRAAL_RELEASE: "vm-21.3.0"
GRAAL_ARTIFACT: "graalvm-ce-java17-linux-amd64-21.3.0"
JAVA_HOME: "/usr/local/lib/graalvm/21.3.0"
GRAAL_RELEASE: "vm-22.0.0.2"
GRAAL_ARTIFACT: "graalvm-ce-java17-linux-amd64-22.0.0.2"

JAVA_HOME: "/usr/local/lib/graalvm/22.0.0.2"
SOURCE_DATE_EPOCH: "1622959566" # Arbitrary: consistent with pom.xml epoch for sentimental reasons

phases:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class LambdaPoller<BodyType,ResponseType> {
private final LambdaRuntimeClient<BodyType,ResponseType> runtimeClient;
private final Function<BodyType,ResponseType> invocationHandler;

public LambdaPoller(LambdaRuntimeClient<BodyType,ResponseType> runtimeClient, Class<BodyType> requestBodyClass,
public LambdaPoller(LambdaRuntimeClient<BodyType,ResponseType> runtimeClient,
Function<BodyType,ResponseType> invocationHandler) {
this.threadExecutor = Executors.newSingleThreadExecutor();
this.runtimeClient = runtimeClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.admiralbot.lambdaruntime;

import com.admiralbot.sharedutil.Utils;

public class LambdaRuntimeUtils {

// https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html#runtimes-custom-build
private static final String HANDLER_ENV_VAR_KEY = "_HANDLER";

private LambdaRuntimeUtils() {}

public static String getHandler() {
return Utils.getEnvOrThrow(HANDLER_ENV_VAR_KEY);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public LambdaProxyApiServer() {
runtimeClient.postInitError(errorMessage, e.getClass().getSimpleName(), null);
throw new RuntimeException(errorMessage, e);
}
lambdaPoller = new LambdaPoller<>(runtimeClient, APIGatewayV2HTTPEvent.class, this::handleRequestWithXray);
lambdaPoller = new LambdaPoller<>(runtimeClient, this::handleRequestWithXray);
}

private APIGatewayV2HTTPResponse handleRequestWithXray(APIGatewayV2HTTPEvent request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand All @@ -11,6 +12,11 @@ public class Utils {

private Utils() {}

public static String getEnvOrThrow(String key) {
return Optional.ofNullable(System.getenv(key)).orElseThrow(() ->
new IllegalArgumentException("Environment variable <" + key + "> does not exist"));
}

public static boolean equalsAny(Object object, Object... options) {
// Original version which IDEA suggested replacement for:
// return Arrays.stream(options).anyMatch(object::equals);
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<awssdk.version>2.17.73</awssdk.version>
<awssdk.version>2.17.131</awssdk.version>
<awsmonocdk.version>1.130.0</awsmonocdk.version>
</properties>

Expand Down Expand Up @@ -50,7 +50,7 @@
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.5</version>
<version>0.9.10</version>
<executions>
<execution>
<goals>
Expand Down

0 comments on commit a292c16

Please sign in to comment.