Skip to content

Commit

Permalink
Update v3.md
Browse files Browse the repository at this point in the history
  • Loading branch information
falvarez1 authored and linkdotnet committed Aug 18, 2024
1 parent b704cfc commit 2be0b29
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/migration/v3.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# v3 Migration Guide

This document will describe the changes made in `v3` of **NCronJob** and how to migrate from `v2`.
This document describes the changes made in `v3` of **NCronJob** and how to migrate from `v2`.

Version 3 of **NCronJob** brings some breaking changes to make a better API.
Version 3 of **NCronJob** introduces some breaking changes to improve the API.

### Second precision is automatically inferred
In `v2` one would define as such:
Expand All @@ -12,7 +12,7 @@ builder.Services.AddNCronJob(
p => p.WithCronExpression("* * * * * *", true)));
```

Inside `WithCronExpression` was an optional parameter that if set to `true` the cron expression has to be in seconds precision. This was a bit confusing and not very intuitive. In `v3` the seconds precision is automatically inferred. So the above code can be simplified to:
Inside `WithCronExpression`, there was an optional parameter that, if set to `true`, required the cron expression to be in _seconds_ precision. This was a bit confusing and not very intuitive. In `v3` the seconds precision is automatically inferred. Therefore, the above code can be simplified to:

```csharp
builder.Services.AddNCronJob(
Expand All @@ -21,7 +21,7 @@ builder.Services.AddNCronJob(
```

### `JobExecutionContext` is now `IJobExecutionContext`
The `JobExecutionContext` class isn't used anymore. It was replaced by an interface `IJobExecutionContext`. This change was made to allow for easier testing and mocking of the context. Until now you always had to pass in a valid instance which was a bit cumbersome. Now you can mock the interface (or provide a fake) and pass it in.
The `JobExecutionContext` class is no longer used. It has been replaced by the `IJobExecutionContext` interface. This change was made to allow for easier testing and mocking of the context. Until now you always had to pass in a valid instance which was a bit cumbersome. Now you can mock the interface (or provide a fake) and pass it in.

For the migration, you just have to change the type of the parameter in your job from `JobExecutionContext` to `IJobExecutionContext`:

Expand Down

0 comments on commit 2be0b29

Please sign in to comment.