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

Avanade / NTangle / 11759370733

09 Nov 2024 08:54PM UTC coverage: 74.159% (+9.7%) from 64.469%
11759370733

Pull #52

github

web-flow
Merge 6df4947c1 into 5cd46db5b
Pull Request #52: v3.0.0

256 of 368 branches covered (69.57%)

Branch coverage included in aggregate %.

830 of 978 new or added lines in 40 files covered. (84.87%)

70 existing lines in 1 file now uncovered.

1199 of 1594 relevant lines covered (75.22%)

28.5 hits per line

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

0.0
/src/NTangle/Services/CdcService.cs
1
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/NTangle
2

3
using CoreEx.Configuration;
4
using CoreEx.Hosting;
5
using Microsoft.Extensions.Logging;
6
using NTangle.Cdc;
7
using System;
8
using System.Threading;
9
using System.Threading.Tasks;
10

11
namespace NTangle.Services
12
{
13
    /// <summary>
14
    /// Provides the base Change Data Capture (CDC) self-orchestrated <see cref="ServiceBase"/> capabilities.
15
    /// </summary>
16
    /// <remarks>Note that no <see cref="IServiceSynchronizer"/> is leveraged; synchronization is the responsibility of the consumer.</remarks>
17
    /// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
18
    /// <param name="logger">The <see cref="ILogger"/>.</param>
19
    /// <param name="settings">The <see cref="SettingsBase"/>.</param>
20
    public abstract class CdcService<TOrchestrator, TEntity>(IServiceProvider serviceProvider, ILogger logger, SettingsBase? settings) : ServiceBase(serviceProvider, logger, settings) where TOrchestrator : notnull, IEntityOrchestrator<TEntity> where TEntity : IEntity
×
21
    {
22
        private int? _maxIterations = null;
×
23

24
        /// <summary>
25
        /// Gets or sets the maximum number of iterations per execution.
26
        /// </summary>
27
        public override int MaxIterations
28
        {
29
            get => _maxIterations ?? Settings.GetCdcValue<int?>(ServiceName, MaxIterationsName) ?? DefaultMaxIterations;
×
30
            set => _maxIterations = value <= 0 ? DefaultMaxIterations : value;
×
31
        }
32

33
        /// <summary>
34
        /// Execute the <typeparamref name="TOrchestrator"/>.
35
        /// </summary>
36
        /// <param name="scopedServiceProvider">The scoped <see cref="IServiceProvider"/>.</param>
37
        /// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
38
        /// <returns><c>true</c> indicates to execute the next iteration (i.e. continue); otherwise, <c>false</c> to stop.</returns>
39
        protected override async Task<bool> ExecuteAsync(IServiceProvider scopedServiceProvider, CancellationToken cancellationToken)
40
        {
×
41
            // Instantiate the orchestrator.
42
            var eo = (TOrchestrator)(scopedServiceProvider.GetService(typeof(TOrchestrator))
×
43
                ?? throw new InvalidOperationException($"Attempted to get service '{typeof(TOrchestrator).FullName}' but null was returned; this would indicate that the service has not been configured correctly."));
×
44

45
            // Execute the orchestrator.
46
            var result = await eo.ExecuteAsync(cancellationToken).ConfigureAwait(false);
×
47

48
            // Where successful and a batch was processed, then the next batch should be attempted immediately; otherwise, retry later.
NEW
49
            return result.IsSuccessful && result.BatchTracker != null;
×
50
        }
×
51
    }
52
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc