Pandatech.PandaVaultClient 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Pandatech.PandaVaultClient --version 2.0.0
NuGet\Install-Package Pandatech.PandaVaultClient -Version 2.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="Pandatech.PandaVaultClient" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pandatech.PandaVaultClient --version 2.0.0
#r "nuget: Pandatech.PandaVaultClient, 2.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 Pandatech.PandaVaultClient as a Cake Addin
#addin nuget:?package=Pandatech.PandaVaultClient&version=2.0.0

// Install Pandatech.PandaVaultClient as a Cake Tool
#tool nuget:?package=Pandatech.PandaVaultClient&version=2.0.0

PandaVaultClient

PandaVaultClient is an internal NuGet package designed to retrieve and apply configurations from an PandaVault service, to your .NET projects. This package offers a seamless way to integrate and manage configurations securely within your applications.

Features

  • Configuration Retrieval: Fetches configuration data from an internal service using HTTP requests with secret authentication.
  • Configuration Application: Applies the fetched configuration data to your .NET projects using Microsoft's Microsoft.Extensions.Configuration.
  • Configuration Refresh: Refreshes the configuration data at a specified interval, allowing for dynamic configuration changes without the need to restart your application.

Installation

PandaVaultClient can be installed via NuGet Package Manager or by adding the following package reference to your project:

dotnet add package Pandatech.PandaVaultClient

Usage

Basic Configuration Retrieval

To use PandaVaultClient within your project, first, ensure you have the necessary environment variables set for the configuration service URL and secret:

// Set environment variables
Environment.SetEnvironmentVariable("PANDAVAULT_URL", "Your_PandaVault_URL");
Environment.SetEnvironmentVariable("PANDAVAULT_SECRET", "Your_PandaVault_Secret");

Then, within your program.cs register the nuget package: After registering on application startup, you can call PandaVault.SetConfigurationsAsync() to fetch and apply the configurations to your project: Additionally, you can map endpoints for PandaVault.GetAllConfigurations() or RefreshConfigurationsAsync to retrieve the configurations.

Program.cs

using Microsoft.AspNetCore.Mvc;
using PandaVaultClient;

var builder = WebApplication.CreateBuilder(args);

builder.Services.RegisterPandaVault();
builder.Services.AddHostedService<Startup>();

var app = builder.Build();

app.MapGet("/configurations", (PandaVault vault, [FromHeader] string secret) => vault.GetAllConfigurations(secret));
app.MapPut("/configurations",
    async (PandaVault vault, [FromHeader] string secret) => await vault.RefreshConfigurationsAsync(secret));

app.Run();

Startup.cs


namespace PandaVaultClient.Test;

public class Startup : IHostedService
{
    private readonly PandaVault _vault;

    public Startup(PandaVault vault)
    {
        _vault = vault;
    }

    public async Task StartAsync(CancellationToken cancellationToken)
    {
        await _vault.SetConfigurationsAsync();
    }

    public Task StopAsync(CancellationToken cancellationToken)
    {
        return Task.CompletedTask;
    }
}

License

Pandatech.PandaVaultClient is licensed under the MIT License.

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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.0 154 3/18/2024
3.0.6 79 3/17/2024
3.0.5 198 12/18/2023
3.0.4 111 12/14/2023
3.0.3 132 11/29/2023
3.0.2 103 11/29/2023
3.0.1 124 11/28/2023
2.1.1 96 11/26/2023
2.1.0 95 11/26/2023
2.0.0 125 11/25/2023
1.0.0 124 11/15/2023

Better implementation, with demo