Skip to content

Commit

Permalink
Version - 2.1 (#5)
Browse files Browse the repository at this point in the history
* type updating

Updated Message types to allow both class and struct to allow for passing of simpler single data type messages for expanding capabilities
Added in some built in encoders to encode specific lower level data types for efficiency and ease of use, also to avoid using JSON encoding when the data types are simple

* updating external references

Updating the externally referenced libraries across the board

* updating actions

updating actions

* fixing build issue

attempting to fix build issues with respect to vsxmd
  • Loading branch information
roger-castaldo authored Jan 30, 2025
1 parent dd28549 commit b510e9a
Show file tree
Hide file tree
Showing 60 changed files with 661 additions and 188 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/unit-test-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Restore dependencies
run: dotnet restore -p:TargetFramework=net8.0 AutomatedTesting
run: dotnet restore -p:TargetFramework=net8.0 -p:BlockMD=true AutomatedTesting
- name: Build-8.0
run: dotnet build --framework net8.0 --no-restore AutomatedTesting
run: dotnet build --framework net8.0 -p:BlockMD=true --no-restore AutomatedTesting
- name: Test-8.0
run: dotnet test --framework net8.0 --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" --collect:"Code Coverage" AutomatedTesting
run: dotnet test --framework net8.0 -p:BlockMD=true --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" --collect:"Code Coverage" AutomatedTesting
- name: report results
uses: bibipkins/dotnet-test-reporter@v1.4.0
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/unittests8x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Restore dependencies
run: dotnet restore -p:TargetFramework=net8.0 AutomatedTesting
run: dotnet restore -p:TargetFramework=net8.0 -p:BlockMD=true AutomatedTesting
- name: Build-8.0
run: dotnet build --framework net8.0 --no-restore AutomatedTesting
run: dotnet build --framework net8.0 -p:BlockMD=true --no-restore AutomatedTesting
- name: Test-8.0
run: dotnet test --framework net8.0 --no-build --verbosity normal AutomatedTesting
run: dotnet test --framework net8.0 -p:BlockMD=true --no-build --verbosity normal AutomatedTesting
14 changes: 0 additions & 14 deletions Abstractions/Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,4 @@
<Title>Abstractions for MQContract</Title>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Vsxmd" Version="1.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<None Update="Readme.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

</Project>
14 changes: 4 additions & 10 deletions Abstractions/Interfaces/IBaseContractConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public interface IBaseContractConnection : IDisposable, IAsyncDisposable
/// <param name="cancellationToken">A cancellation token</param>
///
/// <returns>A subscription instance that can be ended when desired</returns>
ValueTask<ISubscription> SubscribeAsync<T>(Func<IReceivedMessage<T>, ValueTask> messageReceived, Action<Exception> errorReceived, string? channel = null, string? group = null, bool ignoreMessageHeader = false, CancellationToken cancellationToken = new CancellationToken())
where T : class;
ValueTask<ISubscription> SubscribeAsync<T>(Func<IReceivedMessage<T>, ValueTask> messageReceived, Action<Exception> errorReceived, string? channel = null, string? group = null, bool ignoreMessageHeader = false, CancellationToken cancellationToken = new CancellationToken());
/// <summary>
/// Called to create a subscription into the underlying service Pub/Sub style and have the messages processed syncrhonously
/// </summary>
Expand All @@ -33,8 +32,7 @@ public interface IBaseContractConnection : IDisposable, IAsyncDisposable
/// <param name="cancellationToken">A cancellation token</param>
///
/// <returns>A subscription instance that can be ended when desired</returns>
ValueTask<ISubscription> SubscribeAsync<T>(Action<IReceivedMessage<T>> messageReceived, Action<Exception> errorReceived, string? channel = null, string? group = null, bool ignoreMessageHeader = false, CancellationToken cancellationToken = new CancellationToken())
where T : class;
ValueTask<ISubscription> SubscribeAsync<T>(Action<IReceivedMessage<T>> messageReceived, Action<Exception> errorReceived, string? channel = null, string? group = null, bool ignoreMessageHeader = false, CancellationToken cancellationToken = new CancellationToken());
/// <summary>
/// Called to create a subscription into the underlying service Query/Reponse style and have the messages processed asynchronously
/// </summary>
Expand All @@ -48,9 +46,7 @@ public interface IBaseContractConnection : IDisposable, IAsyncDisposable
/// <param name="cancellationToken">A cancellation token</param>
///
/// <returns>A subscription instance that can be ended when desired</returns>
ValueTask<ISubscription> SubscribeQueryAsyncResponseAsync<Q, R>(Func<IReceivedMessage<Q>, ValueTask<QueryResponseMessage<R>>> messageReceived, Action<Exception> errorReceived, string? channel = null, string? group = null, bool ignoreMessageHeader = false, CancellationToken cancellationToken = new CancellationToken())
where Q : class
where R : class;
ValueTask<ISubscription> SubscribeQueryAsyncResponseAsync<Q, R>(Func<IReceivedMessage<Q>, ValueTask<QueryResponseMessage<R>>> messageReceived, Action<Exception> errorReceived, string? channel = null, string? group = null, bool ignoreMessageHeader = false, CancellationToken cancellationToken = new CancellationToken());
/// <summary>
/// Called to create a subscription into the underlying service Query/Reponse style and have the messages processed synchronously
/// </summary>
Expand All @@ -64,9 +60,7 @@ public interface IBaseContractConnection : IDisposable, IAsyncDisposable
/// <param name="cancellationToken">A cancellation token</param>
///
/// <returns>A subscription instance that can be ended when desired</returns>
ValueTask<ISubscription> SubscribeQueryResponseAsync<Q, R>(Func<IReceivedMessage<Q>, QueryResponseMessage<R>> messageReceived, Action<Exception> errorReceived, string? channel = null, string? group = null, bool ignoreMessageHeader = false, CancellationToken cancellationToken = new CancellationToken())
where Q : class
where R : class;
ValueTask<ISubscription> SubscribeQueryResponseAsync<Q, R>(Func<IReceivedMessage<Q>, QueryResponseMessage<R>> messageReceived, Action<Exception> errorReceived, string? channel = null, string? group = null, bool ignoreMessageHeader = false, CancellationToken cancellationToken = new CancellationToken());
/// <summary>
/// Called to close off the contract connection and close it's underlying service connection
/// </summary>
Expand Down
13 changes: 4 additions & 9 deletions Abstractions/Interfaces/IContractConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public interface IContractConnection : IBaseContractConnection
/// <param name="cancellationToken">A cancellation token</param>
///
/// <returns>A result indicating the tranmission results</returns>
ValueTask<TransmissionResult> PublishAsync<T>(T message, string? channel = null, MessageHeader? messageHeader = null, CancellationToken cancellationToken = new CancellationToken())
where T : class;
ValueTask<TransmissionResult> PublishAsync<T>(T message, string? channel = null, MessageHeader? messageHeader = null, CancellationToken cancellationToken = new CancellationToken());
/// <summary>
/// Called to send a bulk set of messages into the underlying service Pub/Sub style
/// </summary>
Expand All @@ -34,8 +33,7 @@ public interface IContractConnection : IBaseContractConnection
/// <param name="cancellationToken">A cancellation token</param>
///
/// <returns>A result indicating the tranmission results</returns>
ValueTask<IEnumerable<TransmissionResult>> BulkPublishAsync<T>(IEnumerable<(T message,MessageHeader? messageHeader)> messages, string? channel = null, CancellationToken cancellationToken = new CancellationToken())
where T : class;
ValueTask<IEnumerable<TransmissionResult>> BulkPublishAsync<T>(IEnumerable<(T message,MessageHeader? messageHeader)> messages, string? channel = null, CancellationToken cancellationToken = new CancellationToken());

/// <summary>
/// Called to send a message into the underlying service in the Query/Response style
Expand All @@ -51,9 +49,7 @@ public interface IContractConnection : IBaseContractConnection
/// <param name="cancellationToken">A cancellation token</param>
///
/// <returns>A result indicating the success or failure as well as the returned message</returns>
ValueTask<QueryResult<R>> QueryAsync<Q, R>(Q message, TimeSpan? timeout = null, string? channel = null, string? responseChannel = null, MessageHeader? messageHeader = null, CancellationToken cancellationToken = new CancellationToken())
where Q : class
where R : class;
ValueTask<QueryResult<R>> QueryAsync<Q, R>(Q message, TimeSpan? timeout = null, string? channel = null, string? responseChannel = null, MessageHeader? messageHeader = null, CancellationToken cancellationToken = new CancellationToken());
/// <summary>
/// Called to send a message into the underlying service in the Query/Response style. The return type is not specified here and is instead obtained from the QueryResponseTypeAttribute
/// attached to the Query message type class.
Expand All @@ -68,7 +64,6 @@ public interface IContractConnection : IBaseContractConnection
/// <param name="cancellationToken">A cancellation token</param>
///
/// <returns>A result indicating the success or failure as well as the returned message</returns>
ValueTask<QueryResult<object>> QueryAsync<Q>(Q message, TimeSpan? timeout = null, string? channel = null, string? responseChannel = null, MessageHeader? messageHeader = null, CancellationToken cancellationToken = new CancellationToken())
where Q : class;
ValueTask<QueryResult<object>> QueryAsync<Q>(Q message, TimeSpan? timeout = null, string? channel = null, string? responseChannel = null, MessageHeader? messageHeader = null, CancellationToken cancellationToken = new CancellationToken());
}
}
3 changes: 1 addition & 2 deletions Abstractions/Interfaces/IMappableContractConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public interface IMappableContractConnection<CC> : IBaseContractConnection
/// <param name="serviceConnectionName">The name of the service connection, not necessarily unique, but can be used for logging and other things</param>
/// <param name="messageServiceConnection">The service connection to use when the message is of type T</param>
/// <returns></returns>
CC RegisterServiceConnection<T>(string serviceConnectionName, IMessageServiceConnection messageServiceConnection)
where T : class;
CC RegisterServiceConnection<T>(string serviceConnectionName, IMessageServiceConnection messageServiceConnection);
/// <summary>
/// Register a service connection to be used when the messageHeader contains the messageHeaderKey and it's value is messageHeaderValue
/// </summary>
Expand Down
6 changes: 2 additions & 4 deletions Abstractions/Interfaces/IMetricContractConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ CC RegisterMiddleware<T>(Func<T> constructInstance)
/// <typeparam name="M">The message type that this middleware is specifically called for</typeparam>
/// <returns>The Contract Connection instance to allow chaining calls</returns>
CC RegisterMiddleware<T, M>()
where T : ISpecificTypeMiddleware<M>
where M : class;
where T : ISpecificTypeMiddleware<M>;
/// <summary>
/// Register a middleware of a given type T to be used by the contract connection
/// </summary>
Expand All @@ -42,8 +41,7 @@ CC RegisterMiddleware<T, M>()
/// <typeparam name="M">The message type that this middleware is specifically called for</typeparam>
/// <returns>The Contract Connection instance to allow chaining calls</returns>
CC RegisterMiddleware<T, M>(Func<T> constructInstance)
where T : ISpecificTypeMiddleware<M>
where M : class;
where T : ISpecificTypeMiddleware<M>;
/// <summary>
/// Called to activate the metrics tracking middleware for this connection instance
/// </summary>
Expand Down
13 changes: 4 additions & 9 deletions Abstractions/Interfaces/IMultiServiceContractConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public interface IMultiServiceContractConnection :
/// <param name="cancellationToken">A cancellation token</param>
///
/// <returns>A result indicating the tranmission results</returns>
ValueTask<MultiTransmissionResult> PublishAsync<T>(T message, string? channel = null, MessageHeader? messageHeader = null, CancellationToken cancellationToken = new CancellationToken())
where T : class;
ValueTask<MultiTransmissionResult> PublishAsync<T>(T message, string? channel = null, MessageHeader? messageHeader = null, CancellationToken cancellationToken = new CancellationToken());
/// <summary>
/// Called to send a bulk set of messages into the underlying services Pub/Sub style
/// </summary>
Expand All @@ -43,8 +42,7 @@ public interface IMultiServiceContractConnection :
/// <param name="cancellationToken">A cancellation token</param>
///
/// <returns>A result indicating the tranmission results</returns>
ValueTask<IEnumerable<MultiTransmissionResult>> BulkPublishAsync<T>(IEnumerable<(T message, MessageHeader? messageHeader)> messages, string? channel = null, CancellationToken cancellationToken = new CancellationToken())
where T : class;
ValueTask<IEnumerable<MultiTransmissionResult>> BulkPublishAsync<T>(IEnumerable<(T message, MessageHeader? messageHeader)> messages, string? channel = null, CancellationToken cancellationToken = new CancellationToken());
/// <summary>
/// Called to send a message into the underlying services in the Query/Response style
/// </summary>
Expand All @@ -59,9 +57,7 @@ public interface IMultiServiceContractConnection :
/// <param name="cancellationToken">A cancellation token</param>
///
/// <returns>A result indicating the success or failure as well as the returned message</returns>
ValueTask<IEnumerable<QueryResult<R>>> QueryAsync<Q, R>(Q message, TimeSpan? timeout = null, string? channel = null, string? responseChannel = null, MessageHeader? messageHeader = null, CancellationToken cancellationToken = new CancellationToken())
where Q : class
where R : class;
ValueTask<IEnumerable<QueryResult<R>>> QueryAsync<Q, R>(Q message, TimeSpan? timeout = null, string? channel = null, string? responseChannel = null, MessageHeader? messageHeader = null, CancellationToken cancellationToken = new CancellationToken());
/// <summary>
/// Called to send a message into the underlying services in the Query/Response style. The return type is not specified here and is instead obtained from the QueryResponseTypeAttribute
/// attached to the Query message type class.
Expand All @@ -76,7 +72,6 @@ public interface IMultiServiceContractConnection :
/// <param name="cancellationToken">A cancellation token</param>
///
/// <returns>A result indicating the success or failure as well as the returned message</returns>
ValueTask<IEnumerable<QueryResult<object>>> QueryAsync<Q>(Q message, TimeSpan? timeout = null, string? channel = null, string? responseChannel = null, MessageHeader? messageHeader = null, CancellationToken cancellationToken = new CancellationToken())
where Q : class;
ValueTask<IEnumerable<QueryResult<object>>> QueryAsync<Q>(Q message, TimeSpan? timeout = null, string? channel = null, string? responseChannel = null, MessageHeader? messageHeader = null, CancellationToken cancellationToken = new CancellationToken());
}
}
1 change: 0 additions & 1 deletion Abstractions/Interfaces/IRecievedMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace MQContract.Interfaces
/// </summary>
/// <typeparam name="T">The class type of the underlying message</typeparam>
public interface IReceivedMessage<out T>
where T : class
{
/// <summary>
/// The unique ID of the received message that was specified on the transmission side
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace MQContract.Interfaces.Middleware
/// This interface represents a Middleware to execute after a Message of the given type T has been decoded from a ServiceMessage to the expected Class
/// </summary>
public interface IAfterDecodeSpecificTypeMiddleware<T> : ISpecificTypeMiddleware<T>
where T : class
{
/// <summary>
/// This is the method invoked as part of the Middleware processing during message decoding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace MQContract.Interfaces.Middleware
/// This interface represents a Middleware to execute Before a specific message type is encoded
/// </summary>
public interface IBeforeEncodeSpecificTypeMiddleware<T> : ISpecificTypeMiddleware<T>
where T : class
{
/// <summary>
/// This is the method invoked as part of the Middle Ware processing during message encoding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/// Base Specific Type Middleware just used to limit Generic Types for Register Middleware
/// </summary>
public interface ISpecificTypeMiddleware<T>
where T : class
{
}
}
3 changes: 1 addition & 2 deletions Abstractions/Messages/QueryResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
/// <param name="Header">The response headers</param>
/// <param name="Result">The resulting response if there was one</param>
/// <param name="Error">The error message for the response if it failed and an error was returned</param>
public record QueryResult<T>(string ID,MessageHeader Header,T? Result=null,string? Error=null)
public record QueryResult<T>(string ID,MessageHeader Header,T? Result=default,string? Error=null)
: TransmissionResult(ID,Error)
where T : class
{}
}
8 changes: 4 additions & 4 deletions AutomatedTesting/AutomatedTesting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<PackageReference Include="Microsoft.Extensions.Diagnostics.Testing" Version="8.10.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="MSTest.TestAdapter" Version="3.7.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.7.3" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
<PackageReference Include="coverlet.msbuild" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit b510e9a

Please sign in to comment.