• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AWSLambdaClientBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.lambda.AWSLambdaClientBuilder的典型用法代码示例。如果您正苦于以下问题:Java AWSLambdaClientBuilder类的具体用法?Java AWSLambdaClientBuilder怎么用?Java AWSLambdaClientBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AWSLambdaClientBuilder类属于com.amazonaws.services.lambda包,在下文中一共展示了AWSLambdaClientBuilder类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: run

import com.amazonaws.services.lambda.AWSLambdaClientBuilder; //导入依赖的package包/类
public TestResult run() {
    final LambdaSeleniumService lambdaService = LambdaInvokerFactory.builder()
            .lambdaClient(AWSLambdaClientBuilder.defaultClient())
            .build(LambdaSeleniumService.class);

    return lambdaService.runTest(request);
}
 
开发者ID:blackboard,项目名称:lambda-selenium,代码行数:8,代码来源:TestInvoker.java


示例2: deploy

import com.amazonaws.services.lambda.AWSLambdaClientBuilder; //导入依赖的package包/类
void deploy(AwsKeyPair keyPair, String region, String zipFilename, String functionName, Proxy proxy) {
    long t = System.currentTimeMillis();
    final AWSCredentialsProvider credentials = new AWSStaticCredentialsProvider(
            new BasicAWSCredentials(keyPair.key, keyPair.secret));

    AWSLambda lambda = AWSLambdaClientBuilder.standard().withCredentials(credentials)
            .withClientConfiguration(Util.createConfiguration(proxy)).withRegion(region).build();

    byte[] bytes;
    try {
        bytes = IOUtils.toByteArray(new FileInputStream(zipFilename));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    DecimalFormat df = new DecimalFormat("0.000");
    log.info("deploying " + zipFilename + ", length=" + df.format(bytes.length / 1024.0 / 1024.0)
            + "MB, to functionName=" + functionName);
    lambda.updateFunctionCode( //
            new UpdateFunctionCodeRequest() //
                    .withFunctionName(functionName) //
                    .withPublish(true) //
                    .withZipFile(ByteBuffer.wrap(bytes)));
    log.info("deployed in " + (System.currentTimeMillis() - t) + "ms");
}
 
开发者ID:davidmoten,项目名称:aws-maven-plugin,代码行数:25,代码来源:LambdaDeployer.java


示例3: testLambdaInvokeSubsegmentContainsFunctionName

import com.amazonaws.services.lambda.AWSLambdaClientBuilder; //导入依赖的package包/类
@Test
public void testLambdaInvokeSubsegmentContainsFunctionName() {
    // Setup test
    AWSLambda lambda = AWSLambdaClientBuilder.standard().withRequestHandlers(new TracingHandler()).withRegion(Regions.US_EAST_1).withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("fake", "fake"))).build();

    AmazonHttpClient amazonHttpClient = new AmazonHttpClient(new ClientConfiguration());
    ConnectionManagerAwareHttpClient apacheHttpClient = Mockito.mock(ConnectionManagerAwareHttpClient.class);
    HttpResponse httpResponse = new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK"));
    BasicHttpEntity responseBody = new BasicHttpEntity();
    responseBody.setContent(new ByteArrayInputStream("null".getBytes(StandardCharsets.UTF_8))); // Lambda returns "null" on successful fn. with no return value
    httpResponse.setEntity(responseBody);

    try {
        Mockito.doReturn(httpResponse).when(apacheHttpClient).execute(Mockito.any(HttpUriRequest.class), Mockito.any(HttpContext.class));
    } catch (IOException e) { }

    Whitebox.setInternalState(amazonHttpClient, "httpClient", apacheHttpClient);
    Whitebox.setInternalState(lambda, "client", amazonHttpClient);

    // Test logic
    Segment segment = AWSXRay.beginSegment("test");

    InvokeRequest request = new InvokeRequest();
    request.setFunctionName("testFunctionName");
    InvokeResult r = lambda.invoke(request);
    System.out.println(r.getStatusCode());
    System.out.println(r);

    Assert.assertEquals(1, segment.getSubsegments().size());
    Assert.assertEquals("Invoke", segment.getSubsegments().get(0).getAws().get("operation"));
    System.out.println(segment.getSubsegments().get(0).getAws());
    Assert.assertEquals("testFunctionName", segment.getSubsegments().get(0).getAws().get("function_name"));
}
 
开发者ID:aws,项目名称:aws-xray-sdk-java,代码行数:34,代码来源:TracingHandlerTest.java


示例4: ConnectorModel

import com.amazonaws.services.lambda.AWSLambdaClientBuilder; //导入依赖的package包/类
public ConnectorModel(Regions region, String profileName) {

        ProfileCredentialsProvider profileCredentialsProvider = new ProfileCredentialsProvider(profileName);

        awsLambdaClient = AWSLambdaClientBuilder.standard()
                .withRegion(region)
                .withCredentials(profileCredentialsProvider)
                .build();
    }
 
开发者ID:satr,项目名称:intellij-idea-plugin-connector-for-aws-lambda,代码行数:10,代码来源:ConnectorModel.java


示例5: resolveAwsLambdaClient

import com.amazonaws.services.lambda.AWSLambdaClientBuilder; //导入依赖的package包/类
protected AWSLambda resolveAwsLambdaClient() {
	AWSLambda resolvedClient = awsLambdaClient;
	if (resolvedClient == null && region != null) {
		resolvedClient = AWSLambdaClientBuilder.standard().withRegion(region).build();
	}
	return requireToBuild(resolvedClient, "an awsLambdaClient or a region is required");
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:8,代码来源:FeignLambdaServiceInvokerClient.java


示例6: execute

import com.amazonaws.services.lambda.AWSLambdaClientBuilder; //导入依赖的package包/类
/**
 * Executes a lambda function and returns the result of the execution.
 */
@Override
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException {

	AmazonKey amazonKey = getAmazonKey( _session, argStruct );

	// Arguments to extract
	String payload = getNamedStringParam( argStruct, "payload", null );
	String functionName = getNamedStringParam( argStruct, "function", null );
	String qualifier = getNamedStringParam( argStruct, "qualifier", null );

	try {

		// Construct the Lambda Client
		InvokeRequest invokeRequest = new InvokeRequest();
		invokeRequest.setInvocationType( InvocationType.Event );
		invokeRequest.setLogType( LogType.Tail );
		invokeRequest.setFunctionName( functionName );
		invokeRequest.setPayload( payload );
		if ( qualifier != null ) {
			invokeRequest.setQualifier( qualifier );
		}

		// Lambda client must be created with credentials
		BasicAWSCredentials awsCreds = new BasicAWSCredentials( amazonKey.getKey(), amazonKey.getSecret() );
		AWSLambda awsLambda = AWSLambdaClientBuilder.standard()
				.withRegion( amazonKey.getAmazonRegion().toAWSRegion().getName() )
				.withCredentials( new AWSStaticCredentialsProvider( awsCreds ) ).build();

		// Execute
		awsLambda.invoke( invokeRequest );

	} catch ( Exception e ) {
		throwException( _session, "AmazonLambdaAsyncExecute: " + e.getMessage() );
		return cfBooleanData.FALSE;
	}

	return cfBooleanData.TRUE;
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:42,代码来源:LambdaAsyncExecute.java


示例7: getFunctionInstance

import com.amazonaws.services.lambda.AWSLambdaClientBuilder; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:kbastani,项目名称:service-block-samples,代码行数:19,代码来源:AWSLambdaConfigurerAdapter.java


示例8: getLambdaClient

import com.amazonaws.services.lambda.AWSLambdaClientBuilder; //导入依赖的package包/类
public AWSLambda getLambdaClient() {
    return AWSLambdaClientBuilder.standard()
            .withRegion(Regions.US_EAST_1)
            .withCredentials(new LambdaCredentialsProvider(amazonProperties))
            .build();
}
 
开发者ID:kbastani,项目名称:service-block-samples,代码行数:7,代码来源:AWSLambdaConfigurerAdapter.java


示例9: execute

import com.amazonaws.services.lambda.AWSLambdaClientBuilder; //导入依赖的package包/类
/**
 * Executes a lambda function and returns the result of the execution.
 */
@Override
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException {

	AmazonKey amazonKey = getAmazonKey( _session, argStruct );

	// Arguments to extract
	String payload = getNamedStringParam( argStruct, "payload", null );
	String functionName = getNamedStringParam( argStruct, "function", null );
	String qualifier = getNamedStringParam( argStruct, "qualifier", null );

	try {

		// Construct the Lambda Client
		InvokeRequest invokeRequest = new InvokeRequest();
		invokeRequest.setInvocationType( InvocationType.RequestResponse );
		invokeRequest.setLogType( LogType.Tail );
		invokeRequest.setFunctionName( functionName );
		invokeRequest.setPayload( payload );
		if ( qualifier != null ) {
			invokeRequest.setQualifier( qualifier );
		}

		// Lambda client must be created with credentials
		BasicAWSCredentials awsCreds = new BasicAWSCredentials( amazonKey.getKey(), amazonKey.getSecret() );
		AWSLambda awsLambda = AWSLambdaClientBuilder.standard()
				.withRegion( amazonKey.getAmazonRegion().toAWSRegion().getName() )
				.withCredentials( new AWSStaticCredentialsProvider( awsCreds ) ).build();

		// Execute and process the results
		InvokeResult result = awsLambda.invoke( invokeRequest );

		// Convert the returned result
		ByteBuffer resultPayload = result.getPayload();
		String resultJson = new String( resultPayload.array(), "UTF-8" );
		Map<String, Object> resultMap = Jackson.fromJsonString( resultJson, Map.class );

		return tagUtils.convertToCfData( resultMap );

	} catch ( Exception e ) {
		throwException( _session, "AmazonLambdaExecute: " + e.getMessage() );
		return cfBooleanData.FALSE;
	}

}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:48,代码来源:LambdaExecute.java



注:本文中的com.amazonaws.services.lambda.AWSLambdaClientBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CompositeComponent类代码示例发布时间:2022-05-22
下一篇:
Java AudioRenderer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap