SnapshotRestore.Registry 1.0.0
Overview
The primary aim of this project is to develop a new API to register and retrieve tasks of type ValueTask
.
The class uses a ConcurrentStack
and a ConcurrentQueue
to store the registered hooks, which are Func<ValueTask>
objects.
The RegisterBeforeSnapshot
and RegisterAfterRestore
methods allow users to register their own hooks, while the InvokeBeforeSnapshotCallbacks
and InvokeAfterRestoreCallbacks
methods allow the caller to invoke these snapstart hooks.
This implementation is used for Snapstart
, a feature that allows for quick restoration of application state.
Sample Usage
/// <summary>
/// Example class to demonstrate usage of SnapshotRestore.Registry library
/// </summary>
public class SnapstartExample
{
private Guid _myExecutionEnvironmentGuid;
public SnapstartExample()
{
// This GUID is set for non-restore use-cases such as testing or if SnapStart is turned off
_myExecutionEnvironmentGuid = new Guid();
// Register the method which will run after each restore. You may need to update Amazon.Lambda.Core to see this
Amazon.Lambda.Core.SnapshotRestore.RegisterAfterRestore(MyAfterRestore);
}
private ValueTask MyAfterRestore()
{
// After we restore this snapshot to a new execution environment, update the GUID
_myExecutionEnvironmentGuid = new Guid();
return ValueTask.CompletedTask;
}
public string Handler()
{
return $"Hello World! My Execution Environment GUID is {_myExecutionEnvironmentGuid}";
}
}
Showing the top 20 packages that depend on SnapshotRestore.Registry.
Packages | Downloads |
---|---|
Amazon.Lambda.RuntimeSupport
Provides a bootstrap and Lambda Runtime API Client to help you to develop custom .NET Core Lambda Runtimes.
|
5 |
Amazon.Lambda.RuntimeSupport
Provides a bootstrap and Lambda Runtime API Client to help you to develop custom .NET Core Lambda Runtimes.
|
3 |
.NET 8.0
- No dependencies.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 5 | 11/19/2024 |