From b4a8a9f4a3c981bb9b20e90abb18fc2d02c7ed73 Mon Sep 17 00:00:00 2001 From: skwasjer <11424653+skwasjer@users.noreply.github.com> Date: Sun, 6 Oct 2024 09:06:27 +0200 Subject: [PATCH] chore: mark configuration extension accepting ILoggerFactory obsolete. --- README.md | 30 ++++++++++--------- .../GlobalConfigurationExtensions.cs | 6 +++- src/Hangfire.Correlate/README.md | 30 ++++++++++--------- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index bf98325..fc5e378 100644 --- a/README.md +++ b/README.md @@ -44,22 +44,9 @@ A continuation job will inherit the correlation id from the parent job, unless e Configure Hangfire to use Correlate. -### Using built-in configuration extensions ### - -Use the Hangfire built-in configuration extensions to enable Correlate. - -```csharp -ILoggerFactory loggerFactory = new LoggerFactory(); -loggerFactory.AddConsole(); - -GlobalConfiguration.Configuration - .UseCorrelate(loggerFactory) - .(...); -``` - ### Using a `IServiceProvider` -Alternatively (but recommended), use `IServiceProvider` to configure Hangfire with Correlate. +Use the configuration extension with `IServiceProvider` to configure Hangfire with Correlate. Add package dependencies: - [Correlate.DependencyInjection](https://github.com/skwasjer/Correlate) @@ -74,6 +61,21 @@ services ); ``` +### Using built-in configuration extensions ### + +Use the Hangfire built-in configuration extensions to enable Correlate. + +> This is no longer the recommended approach and will most likely be removed in a future version. + +```csharp +ILoggerFactory loggerFactory = new LoggerFactory(); +loggerFactory.AddConsole(); + +GlobalConfiguration.Configuration + .UseCorrelate(loggerFactory) + .(...); +``` + ## Enqueue jobs This example illustrates how jobs that are enqueued, inherit the Correlation ID from the ambient correlation context if inside one. diff --git a/src/Hangfire.Correlate/GlobalConfigurationExtensions.cs b/src/Hangfire.Correlate/GlobalConfigurationExtensions.cs index ba8afd7..d1b1e77 100644 --- a/src/Hangfire.Correlate/GlobalConfigurationExtensions.cs +++ b/src/Hangfire.Correlate/GlobalConfigurationExtensions.cs @@ -32,7 +32,10 @@ public static IGlobalConfiguration UseCorrelate(this IGlobalConfiguration config } catch (InvalidOperationException ex) { - throw new InvalidOperationException("Failed to register Correlate with Hangfire. Please ensure `.AddCorrelate()` is called on the service collection.", ex); + throw new InvalidOperationException( + "Failed to register Correlate with Hangfire. Please ensure `.AddCorrelate()` is called on the service collection.", + ex + ); } } @@ -41,6 +44,7 @@ public static IGlobalConfiguration UseCorrelate(this IGlobalConfiguration config /// /// The global configuration. /// The logger factory. + [Obsolete("Use the overload accepting an IServiceProvider.")] public static IGlobalConfiguration UseCorrelate(this IGlobalConfiguration configuration, ILoggerFactory loggerFactory) { if (configuration is null) diff --git a/src/Hangfire.Correlate/README.md b/src/Hangfire.Correlate/README.md index 7a0a109..bf8e4c5 100644 --- a/src/Hangfire.Correlate/README.md +++ b/src/Hangfire.Correlate/README.md @@ -4,22 +4,9 @@ Configure Hangfire to use Correlate. -### Using built-in configuration extensions ### - -Use the Hangfire built-in configuration extensions to enable Correlate. - -```csharp -ILoggerFactory loggerFactory = new LoggerFactory(); -loggerFactory.AddConsole(); - -GlobalConfiguration.Configuration - .UseCorrelate(loggerFactory) - .(...); -``` - ### Using a `IServiceProvider` -Alternatively (but recommended), use `IServiceProvider` to configure Hangfire with Correlate. +Use the configuration extension with `IServiceProvider` to configure Hangfire with Correlate. Add package dependencies: - [Correlate.DependencyInjection](https://github.com/skwasjer/Correlate) @@ -34,6 +21,21 @@ services ); ``` +### Using built-in configuration extensions ### + +Use the Hangfire built-in configuration extensions to enable Correlate. + +> This is no longer the recommended approach and will most likely be removed in a future version. + +```csharp +ILoggerFactory loggerFactory = new LoggerFactory(); +loggerFactory.AddConsole(); + +GlobalConfiguration.Configuration + .UseCorrelate(loggerFactory) + .(...); +``` + ## Enqueue jobs This example illustrates how jobs that are enqueued, inherit the Correlation ID from the ambient correlation context if inside one.