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

ImmediatePlatform / Immediate.Jobs / 31039674420

05 Aug 2026 07:29PM UTC coverage: 84.091% (+0.2%) from 83.927%
31039674420

push

github

web-flow
Update Extension method namespace to match IP (#99)

* Clean up `IJobScheduler`

* Migrate extension methods for consistency with IP products

* Test namespace propagation

* Add `ImmediateAsssemblyIdentifier` tests

33 of 34 new or added lines in 3 files covered. (97.06%)

3 existing lines in 2 files now uncovered.

8267 of 9831 relevant lines covered (84.09%)

2.72 hits per line

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

93.18
/src/Immediate.Jobs.Shared/ServiceCollectionExtensions.cs
1
using System.Diagnostics.CodeAnalysis;
2
using Microsoft.Extensions.DependencyInjection;
3
using Microsoft.Extensions.DependencyInjection.Extensions;
4
using Microsoft.Extensions.Diagnostics.HealthChecks;
5
using Microsoft.Extensions.Hosting;
6

7
namespace Immediate.Jobs.Shared;
8

9
/// <summary>Runtime registration methods used by generated application extensions.</summary>
10
public static class ImmediateJobsRuntimeServiceCollectionExtensions
11
{
12
        /// <summary>Adds the scheduler runtime. Application code normally calls generated AddImmediateJobs instead.</summary>
13
        /// <param name="services">The service collection to which the runtime is added.</param>
14
        /// <param name="configure">An optional callback that configures the runtime.</param>
15
        /// <returns>A builder for selecting storage and adding runtime integrations.</returns>
16
        public static ImmediateJobsBuilder AddImmediateJobsCore(
17
                this IServiceCollection services,
18
                Action<ImmediateJobsOptions>? configure = null
19
        )
20
        {
21
                ArgumentNullException.ThrowIfNull(services);
4✔
22

23
                var options = new ImmediateJobsOptions();
4✔
24
                configure?.Invoke(options);
4✔
25
                if (options.StorageFactory is null)
4✔
26
                {
27
                        if (options.StorageModeExplicitlySelected)
4✔
28
                                throw new ImmediateJobException("Select a durable storage provider before choosing single-server or distributed mode.");
4✔
29

30
                        _ = options.UseInMemory();
4✔
31
                }
32

33
                options.Validate();
4✔
34

35
                services.TryAddSingleton(options);
4✔
36
                services.TryAddSingleton(TimeProvider.System);
4✔
37
                services.TryAddSingleton<IIdGenerator>(GuidIdGenerator.Instance);
4✔
38
                services.TryAddSingleton<IJobSerializer, SystemTextJsonJobSerializer>();
4✔
39
                services.TryAddSingleton(options.CreateStorage);
4✔
40
                services.TryAddSingleton(static sp =>
4✔
41
                        sp.GetRequiredService<IJobStorage>() as IRecurringJobStorage
4✔
42
                                ?? null!);
4✔
43
                services.TryAddSingleton(static sp =>
4✔
44
                        sp.GetRequiredService<IJobStorage>() as IJobGraphStorage
4✔
45
                                ?? null!);
4✔
46
                services.TryAddScoped<JobBatchScheduler>();
4✔
47
                services.TryAddScoped<IJobBatchScheduler>(static sp =>
4✔
48
                        sp.GetService<IJobGraphStorage>() is null
4✔
49
                                ? null!
4✔
50
                                : sp.GetRequiredService<JobBatchScheduler>());
4✔
51
                services.TryAddScoped<JobMonitor>();
4✔
52
                services.TryAddScoped<IJobBatchMonitor>(static sp =>
4✔
53
                        sp.GetService<IJobGraphStorage>() is null
4✔
54
                                ? null!
4✔
55
                                : sp.GetRequiredService<JobMonitor>());
4✔
56
                services.TryAddScoped<IJobMonitor>(static sp =>
4✔
57
                        sp.GetRequiredService<JobMonitor>());
4✔
58
                _ = services.AddSingleton(JobQueueDefinition.Default);
4✔
59
                services.TryAddSingleton<JobSchedulerState>();
4✔
60
                services.TryAddSingleton<JobSchedulerService>();
4✔
61
                _ = services.AddSingleton<IHostedService>(
4✔
62
                        static sp => sp.GetRequiredService<JobSchedulerService>()
4✔
63
                );
4✔
64
                return new(services);
4✔
65
        }
66

67
        /// <summary>Replaces the default GUID job and batch identifier generator.</summary>
68
        /// <typeparam name="TGenerator">The identifier generator implementation.</typeparam>
69
        /// <param name="builder">The Immediate.Jobs builder.</param>
70
        /// <returns>The supplied builder.</returns>
71
        public static ImmediateJobsBuilder UseIdGenerator<
72
                [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TGenerator
73
        >(
74
                this ImmediateJobsBuilder builder
75
        )
76
                where TGenerator : class, IIdGenerator
77
        {
78
                ArgumentNullException.ThrowIfNull(builder);
4✔
79
                _ = builder.Services.Replace(ServiceDescriptor.Singleton<IIdGenerator, TGenerator>());
4✔
80
                return builder;
4✔
81
        }
82

83
        /// <summary>Adds scheduler liveness and storage connectivity to the health-check system.</summary>
84
        /// <param name="builder">The Immediate.Jobs builder.</param>
85
        /// <param name="name">The registered health-check name.</param>
86
        /// <param name="failureStatus">The status reported when the check fails.</param>
87
        /// <param name="tags">The tags associated with the health check.</param>
88
        /// <returns>The supplied builder.</returns>
89
        public static ImmediateJobsBuilder AddHealthCheck(
90
                this ImmediateJobsBuilder builder,
91
                string name = "immediate-jobs",
92
                HealthStatus? failureStatus = null,
93
                IEnumerable<string>? tags = null
94
        )
95
        {
96
                ArgumentNullException.ThrowIfNull(builder);
×
NEW
97
                _ = builder.Services.AddHealthChecks().AddCheck<ImmediateJobsHealthCheck>(name, failureStatus, tags ?? []);
×
98
                return builder;
×
99
        }
100
}
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