• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ImmediatePlatform / Immediate.Jobs / 30304771671

27 Jul 2026 08:56PM UTC coverage: 65.995%. First build
30304771671

Pull #33

github

web-flow
Merge 46c3047f1 into e9a147742
Pull Request #33: Improve Storage API

1521 of 2481 new or added lines in 28 files covered. (61.31%)

4326 of 6555 relevant lines covered (66.0%)

2.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

35.71
/src/Immediate.Jobs.Redis/RedisServiceCollectionExtensions.cs
1
using Microsoft.Extensions.DependencyInjection;
2
using StackExchange.Redis;
3

4
namespace Immediate.Jobs.Redis;
5

6
/// <summary>Registers Redis job storage.</summary>
7
public static class RedisServiceCollectionExtensions
8
{
9
        /// <summary>Selects Redis as the distributed Immediate.Jobs queue and recurring provider.</summary>
10
        /// <remarks>
11
        /// Redis does not implement graph storage, so batches and continuations require a SQL provider.
12
        /// This method always selects distributed mode; single-server mode requires a full-capability
13
        /// durable replica and is not supported by the Redis provider.
14
        /// </remarks>
15
        public static ImmediateJobsOptions UseRedis(
16
                this ImmediateJobsOptions jobs,
17
                string configuration,
18
                Action<RedisJobStorageOptions>? configure = null
19
        )
20
        {
NEW
21
                ArgumentNullException.ThrowIfNull(jobs);
×
NEW
22
                ArgumentException.ThrowIfNullOrWhiteSpace(configuration);
×
NEW
23
                var options = CreateOptions(configure);
×
NEW
24
                return jobs
×
NEW
25
                        .UseStorage(services => new RedisJobStorage(
×
NEW
26
                                ConnectionMultiplexer.Connect(configuration),
×
NEW
27
                                options,
×
NEW
28
                                services.GetService<TimeProvider>(),
×
NEW
29
                                ownsConnection: true
×
NEW
30
                        ))
×
NEW
31
                        .UseDistributed();
×
32
        }
33

34
        /// <summary>Selects an application-owned Redis connection as the distributed job provider.</summary>
35
        /// <remarks>
36
        /// Redis does not implement graph storage, so batches and continuations require a SQL provider.
37
        /// The supplied connection is not disposed by the job provider.
38
        /// </remarks>
39
        public static ImmediateJobsOptions UseRedis(
40
                this ImmediateJobsOptions jobs,
41
                IConnectionMultiplexer connection,
42
                Action<RedisJobStorageOptions>? configure = null
43
        )
44
        {
45
                ArgumentNullException.ThrowIfNull(jobs);
1✔
46
                ArgumentNullException.ThrowIfNull(connection);
1✔
47
                var options = CreateOptions(configure);
1✔
48
                return jobs
1✔
NEW
49
                        .UseStorage(services => new RedisJobStorage(
×
NEW
50
                                connection,
×
NEW
51
                                options,
×
NEW
52
                                services.GetService<TimeProvider>(),
×
NEW
53
                                ownsConnection: false
×
NEW
54
                        ))
×
55
                        .UseDistributed();
1✔
56
        }
57

58
        private static RedisJobStorageOptions CreateOptions(Action<RedisJobStorageOptions>? configure)
59
        {
60
                var options = new RedisJobStorageOptions();
1✔
61
                configure?.Invoke(options);
1✔
62
                ArgumentException.ThrowIfNullOrWhiteSpace(options.KeyPrefix);
1✔
63
                if (options.KeyPrefix.IndexOfAny(['{', '}']) >= 0)
1✔
NEW
64
                        throw new ArgumentException("The Redis key prefix cannot contain '{' or '}'.", nameof(configure));
×
65
                return options;
1✔
66
        }
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc