Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: mark configuration extension accepting ILoggerFactory obsolete. #51

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion src/Hangfire.Correlate/GlobalConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}

Expand All @@ -41,6 +44,7 @@ public static IGlobalConfiguration UseCorrelate(this IGlobalConfiguration config
/// </summary>
/// <param name="configuration">The global configuration.</param>
/// <param name="loggerFactory">The logger factory.</param>
[Obsolete("Use the overload accepting an IServiceProvider.")]
public static IGlobalConfiguration UseCorrelate(this IGlobalConfiguration configuration, ILoggerFactory loggerFactory)
{
if (configuration is null)
Expand Down
30 changes: 16 additions & 14 deletions src/Hangfire.Correlate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down
Loading