com.amazonaws.services.lambda.invoke.LambdaInvokerFactory Java Examples

The following examples show how to use com.amazonaws.services.lambda.invoke.LambdaInvokerFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FederationServiceProvider.java    From aws-athena-query-federation with Apache License 2.0 5 votes vote down vote up
public static FederationService getService(String lambdaFunction, FederatedIdentity identity, String catalog)
{
    FederationService service = serviceCache.get(lambdaFunction);
    if (service != null) {
        return service;
    }

    service = LambdaInvokerFactory.builder()
            .lambdaClient(AWSLambdaClientBuilder.defaultClient())
            .objectMapper(VersionedObjectMapperFactory.create(BLOCK_ALLOCATOR))
            .lambdaFunctionNameResolver(new Mapper(lambdaFunction))
            .build(FederationService.class);

    PingRequest pingRequest = new PingRequest(identity, catalog, generateQueryId());
    PingResponse pingResponse = (PingResponse) service.call(pingRequest);

    int actualSerDeVersion = pingResponse.getSerDeVersion();
    log.info("SerDe version for function {}, catalog {} is {}", lambdaFunction, catalog, actualSerDeVersion);

    if (actualSerDeVersion != SERDE_VERSION) {
        service = LambdaInvokerFactory.builder()
                .lambdaClient(AWSLambdaClientBuilder.defaultClient())
                .objectMapper(VersionedObjectMapperFactory.create(BLOCK_ALLOCATOR, actualSerDeVersion))
                .lambdaFunctionNameResolver(new Mapper(lambdaFunction))
                .build(FederationService.class);
    }

    serviceCache.put(lambdaFunction, service);
    return service;
}
 
Example #2
Source File: TestInvoker.java    From lambda-selenium with MIT License 5 votes vote down vote up
public TestResult run() {
    final LambdaSeleniumService lambdaService = LambdaInvokerFactory.builder()
            .lambdaClient(AWSLambdaClientBuilder.defaultClient())
            .build(LambdaSeleniumService.class);

    return lambdaService.runTest(request);
}
 
Example #3
Source File: FeignLambdaServiceInvokerClient.java    From jrestless with Apache License 2.0 5 votes vote down vote up
FeignLambdaServiceInvokerClient(LambdaInvokerFactory.Builder builder, AWSLambda awsLambdaClient,
		String functionName, String functionAlias, String functionVersion) {
	requireNonNull(awsLambdaClient);
	requireNonNull(functionName);
	service = builder
			.lambdaFunctionNameResolver((method, annotation, config) -> functionName)
			.functionAlias(functionAlias)
			.functionVersion(functionVersion)
			.lambdaClient(awsLambdaClient)
			.build(LambdaInvokerService.class);
}
 
Example #4
Source File: FeignLambdaServiceInvokerClientTest.java    From jrestless with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setup() {
	lambdaInvokerFactoryBuilder = mock(LambdaInvokerFactory.Builder.class);
	when(lambdaInvokerFactoryBuilder.lambdaFunctionNameResolver(any())).thenReturn(lambdaInvokerFactoryBuilder);
	when(lambdaInvokerFactoryBuilder.functionAlias(any())).thenReturn(lambdaInvokerFactoryBuilder);
	when(lambdaInvokerFactoryBuilder.functionVersion(any())).thenReturn(lambdaInvokerFactoryBuilder);
	when(lambdaInvokerFactoryBuilder.lambdaClient(any())).thenReturn(lambdaInvokerFactoryBuilder);
	when(lambdaInvokerFactoryBuilder.build(LambdaInvokerService.class)).thenReturn(service);
}
 
Example #5
Source File: FeignLambdaServiceInvokerClient.java    From jrestless with Apache License 2.0 4 votes vote down vote up
public FeignLambdaServiceInvokerClient(@Nonnull AWSLambda awsLambdaClient, @Nonnull String functionName,
		@Nullable String functionAlias, @Nullable String functionVersion) {
	this(LambdaInvokerFactory.builder(), awsLambdaClient, functionName, functionAlias, functionVersion);
}
 
Example #6
Source File: AWSLambdaConfigurerAdapter.java    From service-block-samples with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a proxy instance of a supplied interface that contains methods annotated with
 * {@link LambdaFunction}. Provides automatic credential support to authenticate with an IAM
 * access keys using {@link BasicSessionCredentials} auto-configured from Spring Boot
 * configuration properties in {@link AmazonProperties}.
 *
 * @param type
 * @param <T>
 * @return
 */
public <T> T getFunctionInstance(Class<T> type) {
    return LambdaInvokerFactory.builder()
            .lambdaClient(AWSLambdaClientBuilder.standard()
                    .withRegion(Regions.US_EAST_1)
                    .withCredentials(new LambdaCredentialsProvider(amazonProperties))
                    .build())
            .build(type);
}