Skip to main content

Provides a Restore Hooks library to help you register before snapshot and after restore hooks.

Total Downloads
11.8M
11,817,897
Published
May 7, 2026
6mo ago

Get Started

dotnet add package SnapshotRestore.Registry --version 1.0.2
ProductVersions
.NET
net10.0net8.0net9.0

README

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}";
    }
}

Downloads by Version

Similar & Alternative Packages

Hand-picked matching NuGet libraries based on tags & ecosystem

Depended On By

Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.