Skip to content

Commit c41faaf

Browse files
authored
Merge pull request #517 from Project-MONAI/AI-627
Ai 627
2 parents 9bc789b + 8ef63a2 commit c41faaf

File tree

25 files changed

+425
-324
lines changed

25 files changed

+425
-324
lines changed

.github/.gitversion.yml

100644100755
+7-5
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ assembly-versioning-scheme: MajorMinorPatchTag
1616
mode: ContinuousDelivery
1717
branches:
1818
main:
19-
tag: ''
19+
label: ''
2020
release:
21-
tag: rc
21+
label: rc
2222
develop:
23-
tag: beta
23+
label: beta
24+
increment: Patch
2425
feature:
25-
tag: alpha.{BranchName}
26+
label: alpha.{BranchName}
2627
pull-request:
27-
tag: pr
28+
label: pr
29+
increment: Patch
2830

2931
ignore:
3032
sha: []

.github/workflows/ci.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
semVer: ${{ steps.gitversion.outputs.semVer }}
4040
preReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}
4141
majorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}
42-
nuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
42+
nuGetVersionV2: ${{ steps.gitversion.outputs.MajorMinorPatch }}
4343

4444
steps:
4545
- uses: actions/checkout@v4
@@ -50,12 +50,17 @@ jobs:
5050
with:
5151
dotnet-version: "8.0.x"
5252

53+
# - name: Install GitVersion
54+
# run: dotnet tool install --global GitVersion.Tool
55+
5356
- name: Install GitVersion
54-
run: dotnet tool install --global GitVersion.Tool
57+
uses: gittools/actions/gitversion/[email protected]
58+
with:
59+
versionSpec: '6.x'
5560

5661
- name: Determine Version
5762
id: gitversion
58-
uses: gittools/actions/gitversion/execute@v0.10.2
63+
uses: gittools/actions/gitversion/execute@v2.0.1
5964
with:
6065
useConfigFile: true
6166
updateAssemblyInfo: true

doc/dependency_decisions.yml

+1
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@
588588
- 8.0.2
589589
- 8.0.3
590590
- 8.0.6
591+
- 8.0.7
591592
:when: 2022-10-14T23:37:16.793Z
592593
:who: mocsharp
593594
:why: MIT (https://github.com/dotnet/runtime/raw/main/LICENSE.TXT)

src/Api/Storage/Payload.cs

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public TimeSpan Elapsed
8686

8787
public int FilesFailedToUpload { get => Files.Count(p => p.IsUploadFailed); }
8888

89+
public Payload() { }
90+
8991
public Payload(string key, string correlationId, string? workflowInstanceId, string? taskId, DataOrigin dataTrigger, uint timeout)
9092
{
9193
Guard.Against.NullOrWhiteSpace(key, nameof(key));

src/Api/packages.lock.json

100644100755
+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
},
4242
"Microsoft.NET.ILLink.Tasks": {
4343
"type": "Direct",
44-
"requested": "[8.0.6, )",
45-
"resolved": "8.0.6",
46-
"contentHash": "E+lDylsTeP4ZiDmnEkiJ5wobnGaIJzFhOgZppznJCb69UZgbh6G3cfv1pnLDLLBx6JAgl0kAlnINDeT3uCuczQ=="
44+
"requested": "[8.0.7, )",
45+
"resolved": "8.0.7",
46+
"contentHash": "iI52ptEKby2ymQ6B7h4TWbFmm85T4VvLgc/HvS45Yr3lgi4IIFbQtjON3bQbX/Vc94jXNSLvrDOp5Kh7SJyFYQ=="
4747
},
4848
"Monai.Deploy.Messaging": {
4949
"type": "Direct",

src/CLI/packages.lock.json

100644100755
+3-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
},
3636
"Microsoft.NET.ILLink.Tasks": {
3737
"type": "Direct",
38-
"requested": "[8.0.6, )",
39-
"resolved": "8.0.6",
40-
"contentHash": "E+lDylsTeP4ZiDmnEkiJ5wobnGaIJzFhOgZppznJCb69UZgbh6G3cfv1pnLDLLBx6JAgl0kAlnINDeT3uCuczQ=="
38+
"requested": "[8.0.7, )",
39+
"resolved": "8.0.7",
40+
"contentHash": "iI52ptEKby2ymQ6B7h4TWbFmm85T4VvLgc/HvS45Yr3lgi4IIFbQtjON3bQbX/Vc94jXNSLvrDOp5Kh7SJyFYQ=="
4141
},
4242
"System.CommandLine.Hosting": {
4343
"type": "Direct",

src/Client.Common/packages.lock.json

100644100755
+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
},
1111
"Microsoft.NET.ILLink.Tasks": {
1212
"type": "Direct",
13-
"requested": "[8.0.6, )",
14-
"resolved": "8.0.6",
15-
"contentHash": "E+lDylsTeP4ZiDmnEkiJ5wobnGaIJzFhOgZppznJCb69UZgbh6G3cfv1pnLDLLBx6JAgl0kAlnINDeT3uCuczQ=="
13+
"requested": "[8.0.7, )",
14+
"resolved": "8.0.7",
15+
"contentHash": "iI52ptEKby2ymQ6B7h4TWbFmm85T4VvLgc/HvS45Yr3lgi4IIFbQtjON3bQbX/Vc94jXNSLvrDOp5Kh7SJyFYQ=="
1616
}
1717
}
1818
}

src/Common/packages.lock.json

100644100755
+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
},
1111
"Microsoft.NET.ILLink.Tasks": {
1212
"type": "Direct",
13-
"requested": "[8.0.6, )",
14-
"resolved": "8.0.6",
15-
"contentHash": "E+lDylsTeP4ZiDmnEkiJ5wobnGaIJzFhOgZppznJCb69UZgbh6G3cfv1pnLDLLBx6JAgl0kAlnINDeT3uCuczQ=="
13+
"requested": "[8.0.7, )",
14+
"resolved": "8.0.7",
15+
"contentHash": "iI52ptEKby2ymQ6B7h4TWbFmm85T4VvLgc/HvS45Yr3lgi4IIFbQtjON3bQbX/Vc94jXNSLvrDOp5Kh7SJyFYQ=="
1616
},
1717
"System.IO.Abstractions": {
1818
"type": "Direct",

src/Configuration/packages.lock.json

100644100755
+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"net8.0": {
55
"Microsoft.NET.ILLink.Tasks": {
66
"type": "Direct",
7-
"requested": "[8.0.6, )",
8-
"resolved": "8.0.6",
9-
"contentHash": "E+lDylsTeP4ZiDmnEkiJ5wobnGaIJzFhOgZppznJCb69UZgbh6G3cfv1pnLDLLBx6JAgl0kAlnINDeT3uCuczQ=="
7+
"requested": "[8.0.7, )",
8+
"resolved": "8.0.7",
9+
"contentHash": "iI52ptEKby2ymQ6B7h4TWbFmm85T4VvLgc/HvS45Yr3lgi4IIFbQtjON3bQbX/Vc94jXNSLvrDOp5Kh7SJyFYQ=="
1010
},
1111
"Ardalis.GuardClauses": {
1212
"type": "Transitive",

src/DicomWebClient/CLI/packages.lock.json

100644100755
+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
},
1515
"Microsoft.NET.ILLink.Tasks": {
1616
"type": "Direct",
17-
"requested": "[8.0.6, )",
18-
"resolved": "8.0.6",
19-
"contentHash": "E+lDylsTeP4ZiDmnEkiJ5wobnGaIJzFhOgZppznJCb69UZgbh6G3cfv1pnLDLLBx6JAgl0kAlnINDeT3uCuczQ=="
17+
"requested": "[8.0.7, )",
18+
"resolved": "8.0.7",
19+
"contentHash": "iI52ptEKby2ymQ6B7h4TWbFmm85T4VvLgc/HvS45Yr3lgi4IIFbQtjON3bQbX/Vc94jXNSLvrDOp5Kh7SJyFYQ=="
2020
},
2121
"Ardalis.GuardClauses": {
2222
"type": "Transitive",

src/DicomWebClient/packages.lock.json

100644100755
+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
},
2424
"Microsoft.NET.ILLink.Tasks": {
2525
"type": "Direct",
26-
"requested": "[8.0.6, )",
27-
"resolved": "8.0.6",
28-
"contentHash": "E+lDylsTeP4ZiDmnEkiJ5wobnGaIJzFhOgZppznJCb69UZgbh6G3cfv1pnLDLLBx6JAgl0kAlnINDeT3uCuczQ=="
26+
"requested": "[8.0.7, )",
27+
"resolved": "8.0.7",
28+
"contentHash": "iI52ptEKby2ymQ6B7h4TWbFmm85T4VvLgc/HvS45Yr3lgi4IIFbQtjON3bQbX/Vc94jXNSLvrDOp5Kh7SJyFYQ=="
2929
},
3030
"Ardalis.GuardClauses": {
3131
"type": "Transitive",

src/InformaticsGateway/Logging/Log.0.General.cs

100644100755
+6
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,11 @@ public static partial class Log
5959

6060
[LoggerMessage(EventId = 13, Level = LogLevel.Critical, Message = "Failed to start {ServiceName}.")]
6161
public static partial void ServiceFailedToStart(this ILogger logger, string serviceName, Exception ex);
62+
63+
[LoggerMessage(EventId = 14, Level = LogLevel.Critical, Message = "All services are unhealthy")]
64+
public static partial void AllServiceUnheathly(this ILogger logger);
65+
66+
[LoggerMessage(EventId = 15, Level = LogLevel.Error, Message = "Some services are unhealthy {list}")]
67+
public static partial void SomeServiceUnheathly(this ILogger logger, string list);
6268
}
6369
}

src/InformaticsGateway/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
using Monai.Deploy.InformaticsGateway.Services.DicomWeb;
3737
using Monai.Deploy.InformaticsGateway.Services.Export;
3838
using Monai.Deploy.InformaticsGateway.Services.Fhir;
39+
using Monai.Deploy.InformaticsGateway.Services.HealthLevel7;
3940
using Monai.Deploy.InformaticsGateway.Services.Http;
4041
using Monai.Deploy.InformaticsGateway.Services.Scp;
4142
using Monai.Deploy.InformaticsGateway.Services.Scu;
@@ -138,7 +139,6 @@ internal static IHostBuilder CreateHostBuilder(string[] args) =>
138139
services.AddSingleton<IScuQueue, ScuQueue>();
139140
services.AddSingleton<IMllpService, MllpService>();
140141

141-
142142
var timeout = TimeSpan.FromSeconds(hostContext.Configuration.GetValue("InformaticsGateway:dicomWeb:clientTimeout", DicomWebConfiguration.DefaultClientTimeout));
143143
services
144144
.AddHttpClient("dicomweb", configure => configure.Timeout = timeout)
@@ -163,7 +163,7 @@ internal static IHostBuilder CreateHostBuilder(string[] args) =>
163163
services.AddHostedService<ScuExportService>();
164164
services.AddHostedService<DicomWebExportService>();
165165
services.AddHostedService<PayloadNotificationService>();
166-
services.AddHostedService<MllpService>();
166+
services.AddHostedService<MllpServiceHost>();
167167
services.AddHostedService<Hl7ExportService>();
168168

169169
})

src/InformaticsGateway/Repositories/MonaiServiceLocator.cs

100644100755
+10-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
using System.Linq;
2020
using System.Reflection;
2121
using Ardalis.GuardClauses;
22+
using Microsoft.Extensions.DependencyInjection;
23+
using Microsoft.Extensions.Hosting;
2224
using Monai.Deploy.InformaticsGateway.Api.Rest;
2325
using Monai.Deploy.InformaticsGateway.Services.Common;
2426

@@ -51,7 +53,13 @@ public Dictionary<string, ServiceStatus> GetServiceStatus()
5153
{
5254
Guard.Against.Null(type, nameof(type));
5355

54-
return (_serviceProvider.GetService(type) as IMonaiService);
56+
var TypeInterface = type.GetInterfaces().FirstOrDefault(i => i.Name == $"I{type.Name}");
57+
if (TypeInterface is null)
58+
{
59+
var service = _serviceProvider.GetServices<IHostedService>()?.FirstOrDefault(i => i.GetType().Name == type.Name);
60+
return service as IMonaiService;
61+
}
62+
return (_serviceProvider.GetService(TypeInterface) as IMonaiService);
5563

5664
}
5765

@@ -67,7 +75,7 @@ private static List<Type> LocateTypes()
6775
return services.Distinct().ToList();
6876
}
6977

70-
private IList<IMonaiService> LocateServices()
78+
private List<IMonaiService> LocateServices()
7179
{
7280
var list = new List<IMonaiService>();
7381
foreach (var t in _types)

src/InformaticsGateway/Services/Connectors/PayloadAssembler.cs

+17-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
using Microsoft.Extensions.DependencyInjection;
2626
using Microsoft.Extensions.Logging;
2727
using Monai.Deploy.InformaticsGateway.Api;
28+
using Monai.Deploy.InformaticsGateway.Api.Rest;
2829
using Monai.Deploy.InformaticsGateway.Api.Storage;
2930
using Monai.Deploy.InformaticsGateway.Database.Api.Repositories;
3031
using Monai.Deploy.InformaticsGateway.Logging;
32+
using Monai.Deploy.InformaticsGateway.Services.Common;
3133
using Monai.Deploy.Messaging.Events;
3234

3335
#nullable enable
@@ -38,7 +40,7 @@ namespace Monai.Deploy.InformaticsGateway.Services.Connectors
3840
/// An in-memory queue for providing any files/DICOM instances received by the Informatics Gateway to
3941
/// other internal services.
4042
/// </summary>
41-
internal sealed partial class PayloadAssembler : IPayloadAssembler, IDisposable
43+
internal sealed partial class PayloadAssembler : IPayloadAssembler, IDisposable, IMonaiService
4244
{
4345
internal const int DEFAULT_TIMEOUT = 5;
4446
private readonly ILogger<PayloadAssembler> _logger;
@@ -56,6 +58,8 @@ public PayloadAssembler(
5658
{
5759
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
5860
_serviceScopeFactory = serviceScopeFactory ?? throw new ArgumentNullException(nameof(serviceScopeFactory));
61+
var scope = _serviceScopeFactory.CreateScope();
62+
var repository = scope.ServiceProvider.GetRequiredService<IPayloadRepository>(); // done here to ensure connection on startup
5963

6064
_workItems = [];
6165
_tokenSource = new CancellationTokenSource();
@@ -69,8 +73,14 @@ public PayloadAssembler(
6973
};
7074
_timer.Elapsed += OnTimedEvent;
7175
_timer.Enabled = true;
76+
77+
Status = ServiceStatus.Running;
7278
}
7379

80+
public string ServiceName { get => nameof(PayloadAssembler); }
81+
82+
public ServiceStatus Status { get; set; } = ServiceStatus.Unknown;
83+
7484
private async Task RemovePendingPayloads()
7585
{
7686
_logger.RemovingPendingPayloads();
@@ -193,6 +203,8 @@ private async Task QueueBucketForNotification(string key, Payload payload)
193203
payload.State = Payload.PayloadState.Move;
194204
var scope = _serviceScopeFactory.CreateScope();
195205
var repository = scope.ServiceProvider.GetRequiredService<IPayloadRepository>();
206+
207+
196208
await repository.UpdateAsync(payload).ConfigureAwait(false);
197209
_logger.PayloadSaved(payload.PayloadId);
198210
_workItems.Add(payload);
@@ -219,9 +231,11 @@ private async Task<Payload> CreateOrGetPayload(string key, string correlationId,
219231

220232
private async Task<Payload> PayloadFactory(string key, string correlationId, string? workflowInstanceId, string? taskId, Messaging.Events.DataOrigin dataOrigin, uint timeout, CancellationToken cancellationToken)
221233
{
234+
var newPayload = new Payload(key, correlationId, workflowInstanceId, taskId, dataOrigin, timeout, null);
222235
var scope = _serviceScopeFactory.CreateScope();
223236
var repository = scope.ServiceProvider.GetRequiredService<IPayloadRepository>();
224-
var newPayload = new Payload(key, correlationId, workflowInstanceId, taskId, dataOrigin, timeout, null);
237+
238+
225239
await repository.AddAsync(newPayload, cancellationToken).ConfigureAwait(false);
226240
_logger.BucketCreated(key, timeout);
227241
return newPayload;
@@ -232,6 +246,7 @@ public void Dispose()
232246
_tokenSource.Cancel();
233247
_payloads.Clear();
234248
_timer.Stop();
249+
Status = ServiceStatus.Stopped;
235250
}
236251
}
237252
}

src/InformaticsGateway/Services/Export/Hl7ExportService.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,38 @@
2828
using Monai.Deploy.InformaticsGateway.Configuration;
2929
using Monai.Deploy.InformaticsGateway.Database.Api.Repositories;
3030
using Monai.Deploy.InformaticsGateway.Logging;
31-
using Monai.Deploy.InformaticsGateway.Api.Mllp;
3231
using Monai.Deploy.Messaging.Common;
3332
using Polly;
33+
using Monai.Deploy.InformaticsGateway.Api.Mllp;
3434

3535
namespace Monai.Deploy.InformaticsGateway.Services.Export
3636
{
3737
internal class Hl7ExportService : ExportServiceBase
3838
{
3939
private readonly ILogger<Hl7ExportService> _logger;
4040
private readonly InformaticsGatewayConfiguration _configuration;
41-
private readonly IMllpService _mllpService;
4241

4342
protected override ushort Concurrency { get; }
4443
public override string RoutingKey { get; }
4544
public override string ServiceName => "DICOM Export HL7 Service";
45+
private readonly IMllpService _mllpService;
4646

4747

4848
public Hl7ExportService(
4949
ILogger<Hl7ExportService> logger,
5050
IServiceScopeFactory serviceScopeFactory,
5151
IOptions<InformaticsGatewayConfiguration> configuration,
52-
IDicomToolkit dicomToolkit)
52+
IDicomToolkit dicomToolkit,
53+
IMllpService mllpService)
5354
: base(logger, configuration, serviceScopeFactory, dicomToolkit)
5455
{
5556
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
5657
_configuration = configuration.Value ?? throw new ArgumentNullException(nameof(configuration));
5758

58-
_mllpService = serviceScopeFactory.CreateScope().ServiceProvider.GetRequiredService<IMllpService>();
5959
RoutingKey = $"{configuration.Value.Messaging.Topics.ExportHL7}";
6060
ExportCompleteTopic = $"{configuration.Value.Messaging.Topics.ExportHl7Complete}";
6161
Concurrency = _configuration.Dicom.Scu.MaximumNumberOfAssociations;
62+
_mllpService = mllpService ?? throw new ArgumentNullException(nameof(mllpService));
6263
}
6364

6465

@@ -159,6 +160,5 @@ protected override Task<ExportRequestDataMessage> ExecuteOutputDataEngineCallbac
159160
{
160161
return Task.FromResult(exportDataRequest);
161162
}
162-
163163
}
164164
}

0 commit comments

Comments
 (0)