Skip to content

AWS Lambda#721

Open
eamsden wants to merge 7 commits into
mainfrom
ea/aws-lambda
Open

AWS Lambda#721
eamsden wants to merge 7 commits into
mainfrom
ea/aws-lambda

Conversation

@eamsden

@eamsden eamsden commented May 29, 2026

Copy link
Copy Markdown
Contributor

What was changed

Add helpers for serverless workers running on AWS Lambda

Why?

SDKs require specific helpers to run effectively on AWS Lambda.

Checklist

  1. Closes

  2. How was this tested:
    Code in a separate PR in samples-dotnet ( Lambda Worker Sample samples-dotnet#152 ) was used to test deploying and running workflows and activities on a Lambda worker.

  3. Any docs updates needed?

fresh Temporal client and worker, runs until the Lambda deadline minus `ShutdownDeadlineBuffer`, then shuts down and runs
configured shutdown hooks.

## Configuration

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do I configure the shutdown timing?

@eamsden eamsden marked this pull request as ready for review June 16, 2026 22:52
@eamsden eamsden requested a review from a team as a code owner June 16, 2026 22:52

@jmaeagle99 jmaeagle99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanted to provide some feedback; still reviewing.

Extensions:

* [Temporalio.Extensions.DiagnosticSource](/api/Temporalio.Extensions.DiagnosticSource.html)
* [Temporalio.Extensions.Aws.Lambda](/api/Temporalio.Extensions.Aws.Lambda.html)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please alphabetize

src/Temporalio/bin/Release/*.snupkg
src/Temporalio.Extensions.DiagnosticSource/bin/Release/*.nupkg
src/Temporalio.Extensions.DiagnosticSource/bin/Release/*.snupkg
src/Temporalio.Extensions.Aws.Lambda/bin/Release/*.nupkg

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please alphabetize

"files": [
"Temporalio/*.csproj",
"Temporalio.Extensions.DiagnosticSource/*.csproj",
"Temporalio.Extensions.Aws.Lambda/*.csproj",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please alphabetize

Comment thread README.md
});
```

#### Client Configuration From Environment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please separate this out from this change and open a separate PR

<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Temporalio.Tests</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please alphabetize (by _Parameter1 element)

/// Gets or sets hooks to run after each invocation's worker has shut down.
/// </summary>
#pragma warning disable CA2227 // The public API intentionally allows replacing the list during configuration.
public IList<Func<CancellationToken, Task>> ShutdownHooks { get; set; } =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I would remove the setter, to avoid accidentally dropping any already-existing hooks when setting a new list (which will now be disallowed). This eliminates the pragma.
  • I would actually change the property type to IReadOnlyCollection<T> and use a private readonly List<T> backing field; return it from the property getter. Add a AddShutdownHook(Func<T>) method that (1) validates the hook is not null, and (2) adds it to the private backing field. This would eliminate the need for downstream item null checking and prevent resets or mutations of the collection.
  • And to take it even further, if consumers don't need to inspect the hook list, just make it internal.

};
config.WorkerOptions.ApplyPostPluginConfiguration();

foreach (var hook in config.ShutdownHooks)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// <returns>A Lambda handler delegate.</returns>
public static Func<object?, ILambdaContext, Task> CreateHandler(
WorkerDeploymentVersion version,
Action<LambdaWorkerConfig> configure) =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be invoked per-invocation as well. I don't think there should be a difference of call behavior just because one is sync and the other is async.

ApplyDeploymentVersion(options, version);
ClearConcurrencyLimitsIfTunerSet(options);
};
config.WorkerOptions.ApplyPostPluginConfiguration();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think forcing the application here is a production smell (because it's doubly called: here and in the worker) and is only necessary for testing without a real worker. I think this should be removed and then have the affected tests simulate the worker behavior.

/// <remarks>
/// Don't expose this until there's a use case.
/// </remarks>
internal Action<TemporalWorkerOptions>? PostPluginConfiguration { get; set; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, could we write our own internal plugin to do it? Would eliminate this new surface area, guarantee last application, show up in worker heartbeat, etc.

@jmaeagle99 jmaeagle99 self-assigned this Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants