Smdn.Extensions.Polly.KeyedRegistry 1.2.0

Prefix Reserved
dotnet add package Smdn.Extensions.Polly.KeyedRegistry --version 1.2.0
                    
NuGet\Install-Package Smdn.Extensions.Polly.KeyedRegistry -Version 1.2.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="Smdn.Extensions.Polly.KeyedRegistry" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Smdn.Extensions.Polly.KeyedRegistry" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Smdn.Extensions.Polly.KeyedRegistry" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Smdn.Extensions.Polly.KeyedRegistry --version 1.2.0
                    
#r "nuget: Smdn.Extensions.Polly.KeyedRegistry, 1.2.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.
#addin nuget:?package=Smdn.Extensions.Polly.KeyedRegistry&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Smdn.Extensions.Polly.KeyedRegistry&version=1.2.0
                    
Install as a Cake Tool

Smdn.Extensions.Polly.KeyedRegistry 1.2.0

Provides the extensions to enable the registration of the ResiliencePipelineProvider<TKey> with the service key to the ServiceCollection. This enables multiple ResiliencePipelineProviders targeting the same type to be registered and to be retrieved individually by specifying the service key.

Usage

The following code illustrates the library features and how to use them.

using Microsoft.Extensions.DependencyInjection;

using Polly;
using Polly.Registry;
using Polly.Registry.KeyedRegistry;

var services = new ServiceCollection();

// Add ResiliencePipeline with service key '1', pipeline key "pipeline1"
services.AddResiliencePipeline<ResiliencePipelineKeyPair, int, string>(
  resiliencePipelineKeyPair: new(ServiceKey: 1, PipelineKey: "pipeline1"),
  configure: static (builder, context) => {
    var (serviceKey, pipelineKey) = (context.PipelineKey.ServiceKey, context.PipelineKey.PipelineKey);
    Console.WriteLine($"Add ResiliencePipeline: ServiceKey={serviceKey}, PipelineKey={pipelineKey}");
    // Add ResiliencePipeline: ServiceKey=1, PipelineKey=pipeline1

    builder.AddTimeout(TimeSpan.FromSeconds(1));
  }
);

// Add ResiliencePipeline with service key '1', pipeline key "pipeline2"
services.AddResiliencePipeline<ResiliencePipelineKeyPair, int, string>(
  resiliencePipelineKeyPair: new(ServiceKey: 1, PipelineKey: "pipeline2"),
  configure: (builder, context) => {
    var (serviceKey, pipelineKey) = (context.PipelineKey.ServiceKey, context.PipelineKey.PipelineKey);
    Console.WriteLine($"Add ResiliencePipeline: ServiceKey={serviceKey}, PipelineKey={pipelineKey}");
    // Add ResiliencePipeline: ServiceKey=1, PipelineKey=pipeline2

    builder.AddRetry(new());
  }
);

// Add ResiliencePipeline with service key '2', pipeline key "pipeline3"
services.AddResiliencePipeline<ResiliencePipelineKeyPair, int, string>(
  resiliencePipelineKeyPair: new(ServiceKey: 2, PipelineKey: "pipeline3"),
  configure: (builder, context) => {
    var (serviceKey, pipelineKey) = (context.PipelineKey.ServiceKey, context.PipelineKey.PipelineKey);
    Console.WriteLine($"Add ResiliencePipeline: ServiceKey={serviceKey}, PipelineKey={pipelineKey}");
    // Add ResiliencePipeline: ServiceKey=2, PipelineKey=pipeline3

    builder.AddCircuitBreaker(new());
  }
);

var serviceProvider = services.BuildServiceProvider();

// Get the ResiliencePipelineProvider registered with the service key '1'
var pipelineProvider1 = serviceProvider.GetRequiredKeyedService<ResiliencePipelineProvider<string>>(serviceKey: 1);

var pipeline1 = pipelineProvider1.GetPipeline("pipeline1");
var pipeline2 = pipelineProvider1.GetPipeline("pipeline2");

// Get the ResiliencePipelineProvider registered with the service key '2'
var pipelineProvider2 = serviceProvider.GetRequiredKeyedService<ResiliencePipelineProvider<string>>(serviceKey: 2);

var pipeline3 = pipelineProvider2.GetPipeline("pipeline3");

// The key type used to register ResiliencePipeline and ResiliencePipelineProvider
record struct ResiliencePipelineKeyPair(int ServiceKey, string PipelineKey) : IResiliencePipelineKeyPair<int, string> { }

More examples can be found on the GitHub repository.

Contributing

This project welcomes contributions, feedbacks and suggestions. You can contribute to this project by submitting Issues or Pull Requests on the GitHub repository.

API List

List of APIs exposed by assembly Smdn.Extensions.Polly.KeyedRegistry-1.2.0 (net8.0)

// Smdn.Extensions.Polly.KeyedRegistry.dll (Smdn.Extensions.Polly.KeyedRegistry-1.2.0)
//   Name: Smdn.Extensions.Polly.KeyedRegistry
//   AssemblyVersion: 1.2.0.0
//   InformationalVersion: 1.2.0+ab57871a61fa98809fd1f62940e326073110502c
//   TargetFramework: .NETCoreApp,Version=v8.0
//   Configuration: Release
//   Referenced assemblies:
//     Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
//     Polly.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=c8a3ffc3f8f825cc
//     Polly.Extensions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=c8a3ffc3f8f825cc
//     System.ComponentModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
//     System.Linq, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
//     System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
#nullable enable annotations

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.DependencyInjection;
using Polly;
using Polly.Registry;
using Polly.Registry.KeyedRegistry;

namespace Polly {
  public static class KeyedResiliencePipelineProviderServiceCollectionExtensions {
    public static IServiceCollection AddResiliencePipeline<TResiliencePipelineKeyPair, TServiceKey, TPipelineKey>(this IServiceCollection services, TResiliencePipelineKeyPair resiliencePipelineKeyPair, Func<TServiceKey, TPipelineKey, TResiliencePipelineKeyPair> createResiliencePipelineKeyPair, Action<ResiliencePipelineBuilder, AddResiliencePipelineContext<TResiliencePipelineKeyPair>> configure) where TResiliencePipelineKeyPair : notnull, IResiliencePipelineKeyPair<TServiceKey, TPipelineKey> where TPipelineKey : notnull {}
    public static IServiceCollection AddResiliencePipeline<TResiliencePipelineKeyPair, TServiceKey, TPipelineKey>(this IServiceCollection services, TResiliencePipelineKeyPair resiliencePipelineKeyPair, Func<TServiceKey, TPipelineKey, TResiliencePipelineKeyPair> createResiliencePipelineKeyPair, Action<ResiliencePipelineRegistryOptions<TResiliencePipelineKeyPair>>? configureRegistryOptions, Action<ResiliencePipelineBuilder, AddResiliencePipelineContext<TResiliencePipelineKeyPair>> configurePipeline) where TResiliencePipelineKeyPair : notnull, IResiliencePipelineKeyPair<TServiceKey, TPipelineKey> where TPipelineKey : notnull {}
    public static IServiceCollection AddResiliencePipeline<TResiliencePipelineKeyPair, TServiceKey, TPipelineKey>(this IServiceCollection services, TServiceKey serviceKey, TPipelineKey pipelineKey, Func<TServiceKey, TPipelineKey, TResiliencePipelineKeyPair> createResiliencePipelineKeyPair, Action<ResiliencePipelineBuilder, AddResiliencePipelineContext<TResiliencePipelineKeyPair>> configure) where TResiliencePipelineKeyPair : notnull, IResiliencePipelineKeyPair<TServiceKey, TPipelineKey> where TPipelineKey : notnull {}
    public static IServiceCollection AddResiliencePipeline<TResiliencePipelineKeyPair, TServiceKey, TPipelineKey>(this IServiceCollection services, TServiceKey serviceKey, TPipelineKey pipelineKey, Func<TServiceKey, TPipelineKey, TResiliencePipelineKeyPair> createResiliencePipelineKeyPair, Action<ResiliencePipelineRegistryOptions<TResiliencePipelineKeyPair>>? configureRegistryOptions, Action<ResiliencePipelineBuilder, AddResiliencePipelineContext<TResiliencePipelineKeyPair>> configurePipeline) where TResiliencePipelineKeyPair : notnull, IResiliencePipelineKeyPair<TServiceKey, TPipelineKey> where TPipelineKey : notnull {}
    public static IServiceCollection AddResiliencePipeline<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TResiliencePipelineKeyPair, TServiceKey, TPipelineKey>(this IServiceCollection services, TResiliencePipelineKeyPair resiliencePipelineKeyPair, Action<ResiliencePipelineBuilder, AddResiliencePipelineContext<TResiliencePipelineKeyPair>> configure) where TResiliencePipelineKeyPair : notnull, IResiliencePipelineKeyPair<TServiceKey, TPipelineKey> where TPipelineKey : notnull {}
  }

  public static class KeyedResiliencePipelineProviderServiceProviderExtensions {
    public static ResiliencePipelineProvider<TPipelineKey>? GetKeyedResiliencePipelineProvider<TPipelineKey>(this IServiceProvider serviceProvider, object? serviceKey, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] Type typeOfKeyPair) where TPipelineKey : notnull {}
  }
}

namespace Polly.Registry.KeyedRegistry {
  public interface IResiliencePipelineKeyPair<TServiceKey, TPipelineKey> where TPipelineKey : notnull {
    TPipelineKey PipelineKey { get; }
    TServiceKey ServiceKey { get; }
  }

  public class KeyedResiliencePipelineProvider<TResiliencePipelineKeyPair, TServiceKey, TPipelineKey> : ResiliencePipelineProvider<TPipelineKey> where TResiliencePipelineKeyPair : notnull, IResiliencePipelineKeyPair<TServiceKey, TPipelineKey> where TPipelineKey : notnull {
    public KeyedResiliencePipelineProvider(TServiceKey serviceKey, ResiliencePipelineProvider<TResiliencePipelineKeyPair> baseProvider, Func<TServiceKey, TPipelineKey, TResiliencePipelineKeyPair> createResiliencePipelineKeyPair) {}

    public ResiliencePipelineProvider<TResiliencePipelineKeyPair> BaseProvider { get; }
    public TServiceKey ServiceKey { get; }

    public override bool TryGetPipeline(TPipelineKey key, [NotNullWhen(true)] out ResiliencePipeline? pipeline) {}
    public override bool TryGetPipeline<TResult>(TPipelineKey key, [NotNullWhen(true)] out ResiliencePipeline<TResult>? pipeline) {}
  }
}
// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.4.1.0.
// Smdn.Reflection.ReverseGenerating.ListApi.Core v1.3.1.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Smdn.Extensions.Polly.KeyedRegistry:

Package Downloads
Smdn.Net.EchonetLite.RouteB.SkStackIP

Skyley Networksの[SKSTACK IP](https://www.skyley.com/wiki/?SKSTACK+IP+for+HAN)を使用して、 スマート電力量メータとの情報伝達手段である「Bルート」を介したECHONET Lite規格の通信を扱うためのAPIを提供します。 ECHONET Lite規格における下位通信層に相当する実装である`SkStackUdpRouteBHandler`クラスをはじめとするAPIを提供します。

Smdn.Net.SmartMeter

Provides a class `SmartMeterDataAggregator`, which implements the **HEMS Controller** that periodically collects the data from the **low-voltage smart electric energy meter** via the **route-B**. 「Bルート」を介して「低圧スマート電力量メータ」から定期的なデータ収集を行う「HEMS コントローラ」の実装であるクラス`SmartMeterDataAggregator`を提供します。

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 354 6/14/2025
1.1.0 248 6/9/2025
1.0.0 223 6/8/2025