SnapshotRestore.Registry 1.0.0

dotnet add package SnapshotRestore.Registry --version 1.0.0                
NuGet\Install-Package SnapshotRestore.Registry -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SnapshotRestore.Registry" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SnapshotRestore.Registry --version 1.0.0                
#r "nuget: SnapshotRestore.Registry, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SnapshotRestore.Registry as a Cake Addin
#addin nuget:?package=SnapshotRestore.Registry&version=1.0.0

// Install SnapshotRestore.Registry as a Cake Tool
#tool nuget:?package=SnapshotRestore.Registry&version=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}";
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SnapshotRestore.Registry:

Package Downloads
Amazon.Lambda.RuntimeSupport

Provides a bootstrap and Lambda Runtime API Client to help you to develop custom .NET Core Lambda Runtimes.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 10,658 11/18/2024