Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jpleger/sqs #30

Open
wants to merge 47 commits into
base: release/0.1.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2bb7035
Update release job
mocsharp Apr 5, 2022
367882e
Skip publishing duplicate nuget packages
mocsharp Apr 5, 2022
05376c0
Requires manual trigger to deploy to NuGet.org
mocsharp Apr 6, 2022
a852ec7
Update ci.yml
mocsharp Apr 6, 2022
da1c02b
Update release job
mocsharp Apr 5, 2022
bfafff0
Skip publishing duplicate nuget packages
mocsharp Apr 5, 2022
529d9c5
Requires manual trigger to deploy to NuGet.org
mocsharp Apr 6, 2022
5fff089
Change target framework to .net standard 2.1
mocsharp Apr 6, 2022
d1450c8
Merge branch 'release/0.1.0' into vchang/netstandard
mocsharp Apr 6, 2022
776b217
Merge pull request #2 from Project-MONAI/vchang/netstandard
mocsharp Apr 6, 2022
f90bf2e
Update GitVersion.yml
mocsharp Apr 6, 2022
649c656
Update GitVersion.yml
mocsharp Apr 6, 2022
fd4e2f6
Update ci.yml
mocsharp Apr 6, 2022
ffcf29a
[Breaking] Unit tests for RabbitMQ plugin (#4)
mocsharp Apr 7, 2022
367ce0f
Event validation & add Task related events (#7)
mocsharp Apr 11, 2022
5a314d3
Add subscription no requeue reject (#9)
jackschofield23 Apr 11, 2022
e3c4c91
New RunnerCompleteEvent (#10)
mocsharp Apr 14, 2022
7fe7ce0
Add additional failure reasons (#11)
mocsharp Apr 14, 2022
2402d20
Update FailureReason.cs
mocsharp Apr 15, 2022
bfc08d9
Ability to convert Message to JsonMessage<T> (#13)
mocsharp Apr 21, 2022
7909d03
Handle corrupted messages (#12)
mocsharp Apr 26, 2022
19b141d
Update TaskUpdateEvent.cs
mocsharp Apr 26, 2022
6436c66
update task dispatch event
jackschofield23 Apr 28, 2022
50c66fc
Make credentials optional in TaskDispatchEvent.Storage (#17)
mocsharp May 5, 2022
bdb5be7
change task status name
jackschofield23 May 6, 2022
f637151
Rename workflow instance id (#20)
jackschofield23 May 10, 2022
5f360a7
Intermediate Storage for TaskDispatchEvent (#21)
mocsharp May 13, 2022
64437ab
Throw MessageConversionException on error converting JSON event messa…
mocsharp May 17, 2022
310d005
update taskupdate to include output artifacts
jackschofield23 May 19, 2022
1761aad
update task callback event (#24)
jackschofield23 May 30, 2022
8f63ccd
fix task callback and task update event (#25)
jackschofield23 May 30, 2022
b076491
add payload id to task dispatch (#26)
jackschofield23 Jun 1, 2022
c167be8
add export status (#28)
jackschofield23 Jun 13, 2022
16a53b7
Options to enable secure RabbitMQ (#27)
jeanpatrickleger Jun 13, 2022
d0ba49e
Added SQS plug-in as RMQ alternative.
jeanpatrickleger Jun 13, 2022
bc71ebd
SQS Support adde to messaging lib
jeanpatrickleger Jun 14, 2022
4edabf0
Code analysis fixes.
jeanpatrickleger Jun 14, 2022
8cdb394
remove unecessary folder.
awsjpleger Jun 14, 2022
75973f0
problematic README.MD removed
jeanpatrickleger Jun 14, 2022
fad266c
README.MD added back.
jeanpatrickleger Jun 14, 2022
4d930e8
Code smells corrections.
jeanpatrickleger Jun 14, 2022
fa737a0
Code smells corrections.
jeanpatrickleger Jun 14, 2022
9fe3d1b
Code smells corrections.
jeanpatrickleger Jun 14, 2022
674029f
Code smells corrections.
jeanpatrickleger Jun 14, 2022
47781e1
Code smells corrections.
jeanpatrickleger Jun 14, 2022
2e5ab53
Code smells corrections.
jeanpatrickleger Jun 14, 2022
ed2f2b5
Code smells corrections.
jeanpatrickleger Jun 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<!--
SPDX-FileCopyrightText: � 2021-2022 MONAI Consortium
SPDX-License-Identifier: Apache License 2.0
-->

Fixes # .

### Description
Expand All @@ -16,7 +11,5 @@ A few sentences describing the changes proposed in this pull request.
- [ ] Non-breaking change (fix or new feature that would not break existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing functionality to change).
- [ ] New tests added to cover the changes.
- [ ] All tests passed locally by running `./src/run-tests-in-docker.sh`.
- [ ] All tests passed locally.
- [ ] [Documentation comments](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/documentation-comments) included/updated.
- [ ] User guide updated.
- [ ] I have updated the changelog
15 changes: 11 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
nuget:
type: boolean
default: false
description: Publish to NuGet.org

env:
BUILD_CONFIG: "Release"
Expand Down Expand Up @@ -206,6 +211,7 @@ jobs:
retention-days: 30

publish:
name: Publish to GitHub Packages
runs-on: ubuntu-latest
needs: [build, unit-test]
steps:
Expand All @@ -223,10 +229,11 @@ jobs:
source-url: https://nuget.pkg.github.com/Project-MONAI/index.json

- name: Publish to GitHub
run: dotnet nuget push ${{ steps.download.outputs.download-path }}/artifact/*.nupkg
run: dotnet nuget push ${{ steps.download.outputs.download-path }}/artifact/*.nupkg --skip-duplicate

release:
if: ${{ contains(github.ref, 'refs/heads/main') ||contains(github.head_ref, 'release/') }}
name: Official Release to NuGet.org
if: ${{ github.event.inputs.nuget || contains(github.ref, 'refs/heads/release') }}
runs-on: ubuntu-latest
needs: [build, unit-test]
env:
Expand Down Expand Up @@ -268,17 +275,17 @@ jobs:
name: Release v${{ env.MAJORMINORPATCH }}

- name: Publish release with GitReleaseManager
uses: gittools/actions/gitreleasemanager/[email protected]
if: ${{ contains(github.ref, 'refs/heads/main') }}
uses: gittools/actions/gitreleasemanager/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ steps.repo.outputs._0 }}
repository: ${{ steps.repo.outputs._1 }}
tagName: ${{ env.MAJORMINORPATCH }}

- name: Close release with GitReleaseManager
uses: gittools/actions/gitreleasemanager/[email protected]
if: ${{ contains(github.ref, 'refs/heads/main') }}
uses: gittools/actions/gitreleasemanager/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ steps.repo.outputs._0 }}
Expand Down
44 changes: 42 additions & 2 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,57 @@
# SPDX-FileCopyrightText: 2022 MONAI Consortium
# SPDX-FileCopyrightText: © 2022 MONAI Consortium
# SPDX-License-Identifier: Apache License 2.0

assembly-versioning-scheme: MajorMinorPatchTag
mode: ContinuousDelivery
mode: ContinuousDeployment
branches:
main:
tag: ''
mode: ContinuousDelivery
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
source-branches: [ 'release' ]
tracks-release-branches: false
is-release-branch: false
is-mainline: true
pre-release-weight: 55000
release:
tag: rc
regex: ^releases?[/-]
mode: ContinuousDeployment
increment: None
prevent-increment-of-merged-branch-version: true
track-merge-target: false
source-branches: [ 'main', 'release' ]
tracks-release-branches: false
is-release-branch: true
is-mainline: false
pre-release-weight: 30000
feature:
tag: alpha.{BranchName}
regex: ^features?[/-]
mode: ContinuousDeployment
increment: Inherit
prevent-increment-of-merged-branch-version: false
track-merge-target: false
source-branches: [ 'main', 'release', 'feature' ]
tracks-release-branches: false
is-release-branch: false
is-mainline: false
pre-release-weight: 30000
pull-request:
tag: pr
regex: ^(pull|pull\-requests|pr)[/-]
mode: ContinuousDeployment
increment: Inherit
prevent-increment-of-merged-branch-version: false
tag-number-pattern: '[/-](?<number>\d+)[-/]'
track-merge-target: false
source-branches: [ 'main', 'release', 'feature' ]
tracks-release-branches: false
is-release-branch: false
is-mainline: false
pre-release-weight: 30000

ignore:
sha: []
Expand Down
2 changes: 1 addition & 1 deletion src/Messaging/API/IMessageBrokerPublisherService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Monai.Deploy.Messaging
{
public interface IMessageBrokerPublisherService
public interface IMessageBrokerPublisherService : IDisposable
{
/// <summary>
/// Gets or sets the name of the storage service.
Expand Down
47 changes: 41 additions & 6 deletions src/Messaging/API/IMessageBrokerSubscriberService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,68 @@

namespace Monai.Deploy.Messaging
{
public interface IMessageBrokerSubscriberService
public interface IMessageBrokerSubscriberService : IDisposable
{
/// <summary>
/// Gets or sets the name of the storage service.
/// </summary>
string Name { get; }

/// <summary>
/// Subscribe to a message topic & queue.
/// Subscribe to a message topic & queue and executes <c>messageReceivedCallback</c> for every message that is received.
/// Either provide a topic, a queue or both.
/// A queue is generated if the name of the queue is not provided.
/// </summary>
/// <param name="topic">Name of the topic to subscribe to</param>
/// <param name="topic">Topic/routing key to bind to</param>
/// <param name="queue">Name of the queue to consume</param>
/// <param name="messageReceivedCallback">Action to be performed when message is received</param>
/// <param name="prefetchCount">Number of unacknowledged messages to receive at once. Defaults to 0.</param>
/// <param name="prefetchCount">Number of unacknowledged messages to receive at once. Defaults to 0.</param>
void Subscribe(string topic, string queue, Action<MessageReceivedEventArgs> messageReceivedCallback, ushort prefetchCount = 0);

/// <summary>
/// Subscribe to a message topic & queue and executes <c>messageReceivedCallback</c> for every message that is received.
/// Either provide a topic, a queue or both.
/// A queue is generated if the name of the queue is not provided.
/// </summary>
/// <param name="topics">Topics/routing keys to bind to</param>
/// <param name="queue">Name of the queue to consume</param>
/// <param name="messageReceivedCallback">Action to be performed when message is received</param>
/// <param name="prefetchCount">Number of unacknowledged messages to receive at once. Defaults to 0.</param>
void Subscribe(string[] topics, string queue, Action<MessageReceivedEventArgs> messageReceivedCallback, ushort prefetchCount = 0);

/// <summary>
/// Subscribe to a message topic & queue and executes <c>messageReceivedCallback</c> asynchronously for every message that is received.
/// Either provide a topic, a queue or both.
/// A queue is generated if the name of the queue is not provided.
/// </summary>
/// <param name="topic">Topic/routing key to bind to</param>
/// <param name="queue">Name of the queue to consume</param>
/// <param name="messageReceivedCallback"><see cref="Func{MessageReceivedEventArgs, Task}"/> to be performed when message is received</param>
/// <param name="prefetchCount">Number of unacknowledged messages to receive at once. Defaults to 0.</param>
void SubscribeAsync(string topic, string queue, Func<MessageReceivedEventArgs, Task> messageReceivedCallback, ushort prefetchCount = 0);

/// <summary>
/// Subscribe to a message topic & queue and executes <c>messageReceivedCallback</c> asynchronously for every message that is received.
/// Either provide a topic, a queue or both.
/// A queue is generated if the name of the queue is not provided.
/// </summary>
/// <param name="topics">Topics/routing keys to bind to</param>
/// <param name="queue">Name of the queue to consume</param>
/// <param name="messageReceivedCallback"><see cref="Func{MessageReceivedEventArgs, Task}"/> to be performed when message is received</param>
/// <param name="prefetchCount">Number of unacknowledged messages to receive at once. Defaults to 0.</param>
void SubscribeAsync(string[] topics, string queue, Func<MessageReceivedEventArgs, Task> messageReceivedCallback, ushort prefetchCount = 0);

/// <summary>
/// Acknowledge receiving of a message with the given token.
/// </summary>
/// <param name="message">Message to be acknowledged.</param>
void Acknowledge(MessageBase message);

/// <summary>
/// Rejects a messags.
/// Rejects a message.
/// </summary>
/// <param name="message">Message to be rejected.</param>
void Reject(MessageBase message);
/// <param name="requeue">Determines if the message should be requeued.</param>
void Reject(MessageBase message, bool requeue = true);
}
}
13 changes: 0 additions & 13 deletions src/Messaging/AssemblyInfo.cs

This file was deleted.

38 changes: 38 additions & 0 deletions src/Messaging/Common/Credentials.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-FileCopyrightText: © 2022 MONAI Consortium
// SPDX-License-Identifier: Apache License 2.0

using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;

namespace Monai.Deploy.Messaging.Common
{
public class Credentials
{
/// <summary>
/// Gets or sets the access key or user name of the credentials pair.
/// </summary>
[JsonProperty(PropertyName = "access_key")]
[Required]
public string AccessKey { get; set; }

/// <summary>
/// Gets or sets the access token or password of the credentials pair.
/// </summary>
[JsonProperty(PropertyName = "access_token")]
[Required]
public string AccessToken { get; set; }

/// <summary>
/// Gets or sets the session token of the credentials pair.
/// </summary>
[JsonProperty(PropertyName = "session_token")]
public string SessionToken { get; set; }

public Credentials()
{
AccessKey = string.Empty;
AccessToken = string.Empty;
SessionToken = string.Empty;
}
}
}
14 changes: 10 additions & 4 deletions src/Messaging/Common/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ public static partial class Log
[LoggerMessage(EventId = 10006, Level = LogLevel.Information, Message = "Sending nack message {messageId} and requeuing.")]
public static partial void SendingNAcknowledgement(this ILogger logger, string messageId);

[LoggerMessage(EventId = 10007, Level = LogLevel.Information, Message = "Nack message sent for message {messageId}.")]
public static partial void NAcknowledgementSent(this ILogger logger, string messageId);
[LoggerMessage(EventId = 10007, Level = LogLevel.Information, Message = "Nack message sent for message {messageId}, requeue={requeue}.")]
public static partial void NAcknowledgementSent(this ILogger logger, string messageId, bool requeue);

[LoggerMessage(EventId = 10008, Level = LogLevel.Information, Message = "Closing connection.")]
public static partial void ClosingConnection(this ILogger logger);
[LoggerMessage(EventId = 10008, Level = LogLevel.Information, Message = "Closing connections.")]
public static partial void ClosingConnections(this ILogger logger);

[LoggerMessage(EventId = 10009, Level = LogLevel.Error, Message = "Invalid or corrupted message received: Queue={queueName}, Topic={topic}, Message ID={messageId}.")]
public static partial void InvalidMessage(this ILogger logger, string queueName, string topic, string messageId, Exception ex);

[LoggerMessage(EventId = 10010, Level = LogLevel.Error, Message = "Exception not handled by the subscriber's callback function: Queue={queueName}, Topic={topic}, Message ID={messageId}.")]
public static partial void ErrorNotHandledByCallback(this ILogger logger, string queueName, string topic, string messageId, Exception ex);
}
}
27 changes: 27 additions & 0 deletions src/Messaging/Common/MessageConversionException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: © 2022 MONAI Consortium
// SPDX-License-Identifier: Apache License 2.0
//
using System.Runtime.Serialization;

namespace Monai.Deploy.Messaging.Common
{
[Serializable]
public class MessageConversionException : Exception
{
public MessageConversionException()
{
}

public MessageConversionException(string message) : base(message)
{
}

public MessageConversionException(string message, Exception innerException) : base(message, innerException)
{
}

protected MessageConversionException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
31 changes: 31 additions & 0 deletions src/Messaging/Common/MessageValidationException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-FileCopyrightText: © 2022 MONAI Consortium
// SPDX-License-Identifier: Apache License 2.0

using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;

namespace Monai.Deploy.Messaging.Common
{
[Serializable]
public class MessageValidationException : Exception
{
public MessageValidationException(List<ValidationResult> errors)
: base(FormatMessage(errors))
{
}

protected MessageValidationException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}

private static string FormatMessage(List<ValidationResult> errors)
{
if (errors is null || errors.Count == 0)
{
return "Invalid message.";
}

return $"Invalid message: {string.Join(',', errors.Select(p => $"{p.ErrorMessage} Path: {string.Join(',', p.MemberNames)}."))}";
}
}
}
Loading