目录
ALEX WANG

feat(conformance): add map suite (#555)

  • feat(conformance): add map suite (13 handlers, 9-4 declared NOT_IMPLEMENTED)
  • 13 map handlers ported; MapEmpty (9-4) intentionally withheld: known SDK divergence (empty-items map emits InvocationCompleted without ContextStarted), declared NotImplemented with reason instead of shipping a failing handler
  • 6 additional gaps (9-2, 9-6, 9-13, 9-14, 9-19, 9-20) formalized as NotImplemented declarations (Java SDK API limitations), attached to MapBasic’s TestingMetadata since CloudFormation rejects unknown top-level template sections
  • CI matrix extended to include map (9 suites total)

Validated live: 13 PASSED, 7 NOT_IMPLEMENTED, 0 FAILED, 0 UNCOVERED

  • ci: reuse a stable per-suite stack, skip cleanup
  • –name conformance-java- with no run-id suffix: each run updates the same CloudFormation stack in place (faster, warm resources)
  • –no-cleanup: keep the stack between runs
  • serialize the workflow globally (queue, no cancel) since concurrent runs would now contend on the same stacks – mirrors e2e-tests.yml
  • ci: drop 9-4 NotImplemented declaration (handler coming in a separate CR)

  • chore: load templates via direct CfnLoader instantiation

CfnLoader extends SafeLoader, so semantics are unchanged; avoids the yaml.load API that untrusted-data scanners flag.

  • chore: factor template loading into _safe_load_cfn helper

Aligns with aws-durable-execution-sdk-js#750 so both repos’ scripts stay line-for-line consistent.

  • chore: ignore sam build output dir; drop accidentally committed artifacts

The conformance runner invokes ‘sam build –build-dir build/‘ relative to its CWD; running it from this directory leaves large local artifacts under build/.


Co-authored-by: Alex Wang wangyb@amazon.com

4天前540次提交

AWS Lambda Durable Execution SDK for Java

License Java Build Javadoc Maven Coverage E2E Tests CodeQL Spotless Roadmap

Build resilient, long-running AWS Lambda functions that automatically checkpoint progress and resume after failures. Durable functions can run for up to one year while you pay only for active compute time.

Key Features

  • Automatic Checkpointing – Progress is saved after each step; failures resume from the last checkpoint
  • Cost-Effective Waits – Suspend execution for minutes, hours, or days without compute charges
  • Configurable Retries – Built-in retry strategies with exponential backoff and jitter
  • Replay Safety – Functions deterministically resume from checkpoints after interruptions
  • Type Safety – Full generic type support for step results
  • Data-Driven Concurrency – Apply a function across a collection with map(), with per-item error isolation and configurable completion criteria

How It Works

Your durable function extends DurableHandler<I, O> and implements handleRequest(I input, DurableContext ctx). The DurableContext is your interface to durable operations:

  • ctx.step() – Execute code and checkpoint the result
  • ctx.wait() – Suspend execution without compute charges
  • ctx.createCallback() – Wait for external events (approvals, webhooks)
  • ctx.waitForCallback() – Simplify callback handling by combining callback creation and submission in one operation
  • ctx.invoke() – Invoke another Lambda function, durable or standard, and wait for the result
  • ctx.runInChildContext() – Run an isolated child context with its own checkpoint log
  • ctx.map() – Apply a function to each item in a collection concurrently
  • ctx.parallel() - Run multiple operations concurrently with optional concurrency control
  • ctx.waitForCondition() – Poll a condition function until it signals done, suspending between polls

Quick Start

Installation

<dependency>
    <groupId>software.amazon.lambda.durable</groupId>
    <artifactId>aws-durable-execution-sdk-java</artifactId>
    <version>VERSION</version>
</dependency>

Your First Durable Function

public class OrderProcessor extends DurableHandler<Order, OrderResult> {

    @Override
    protected OrderResult handleRequest(Order order, DurableContext ctx) {
        // Step 1: Validate and reserve inventory
        var reservation = ctx.step("reserve-inventory", Reservation.class, 
            stepCtx -> inventoryService.reserve(order.getItems()));

        // Step 2: Process payment
        var payment = ctx.step("process-payment", Payment.class,
            stepCtx -> paymentService.charge(order.getPaymentMethod(), order.getTotal()));

        // Wait for warehouse processing (no compute charges)
        ctx.wait(null, Duration.ofHours(2));

        // Step 3: Confirm shipment
        var shipment = ctx.step("confirm-shipment", Shipment.class,
            stepCtx -> shippingService.ship(reservation, order.getAddress()));

        return new OrderResult(order.getId(), shipment.getTrackingNumber());
    }
}

Deployment

See examples/README.md for complete instructions on local testing and running cloud integration tests.

See Deploy and invoke Lambda durable functions with the AWS CLI for more information on deploying and invoking durable functions.

See Deploy Lambda durable functions with Infrastructure as Code for more information on deploying durable functions using infrastructure-as-code.

Documentation

  • AWS Documentation – Official AWS Lambda durable functions guide
  • Best Practices – Patterns and recommendations
  • FAQ - Frequently asked questions for the Java SDK
  • Javadoc - API reference for the Java SDK
  • SDK Design – Details of SDK internal architecture

Core Operations

  • Steps – Execute code with automatic checkpointing and retry support
  • Wait - Pause execution without blocking Lambda resources
  • Callbacks - Wait for external systems to respond
  • Invoke - Call durable functions or standard Lambda functions
  • Child Contexts - Organize complex workflows into isolated units
  • Map - Apply a function across a collection concurrently
  • Parallel - Run multiple operations concurrently with optional concurrency control
  • Wait for Condition - Poll a condition until it’s met, with configurable backoff

Examples

  • Examples - Working examples of each operation

Advanced Topics

Security

See CONTRIBUTING for information about reporting security issues.

License

This project is licensed under the Apache-2.0 License. See LICENSE for details.

关于
42.0 MB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号