-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsonJobQueueSchema.cs
More file actions
35 lines (33 loc) · 1.27 KB
/
JsonJobQueueSchema.cs
File metadata and controls
35 lines (33 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Threading;
using System.Threading.Tasks;
using Birko.BackgroundJobs.JSON.Models;
using Birko.Data.JSON.Stores;
using Birko.Data.Stores;
using Birko.Configuration;
namespace Birko.BackgroundJobs.JSON
{
/// <summary>
/// Utility for managing the background jobs JSON file.
/// </summary>
public static class JsonJobQueueSchema
{
/// <summary>
/// Creates the jobs file. Called automatically by JsonJobQueue on first use.
/// </summary>
public static async Task EnsureCreatedAsync(Birko.Configuration.Settings settings, CancellationToken cancellationToken = default)
{
var store = new AsyncJsonStore<JsonJobDescriptorModel>();
store.SetSettings(settings);
await store.InitAsync(cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Deletes the jobs file. WARNING: This deletes all job data.
/// </summary>
public static async Task DropAsync(Birko.Configuration.Settings settings, CancellationToken cancellationToken = default)
{
var store = new AsyncJsonStore<JsonJobDescriptorModel>();
store.SetSettings(settings);
await store.DestroyAsync(cancellationToken).ConfigureAwait(false);
}
}
}