Skip to content

Commit

Permalink
Add OfX-RabbitMq.
Browse files Browse the repository at this point in the history
Also update the document for all OfX ecosystem.
Update Some Nats class or interface... scope to make them more private!
Happy coding. Yep, upgrade to v 3.1.8!
  • Loading branch information
quyvu01 committed Jan 8, 2025
1 parent ee2a74c commit 3ef2dde
Show file tree
Hide file tree
Showing 35 changed files with 290 additions and 137 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ public class UserRequestHandler(): IMappableRequestHandler<UserOfAttribute>

Enjoy your moment!

| Package Name | Description | .NET Version | Document |
|----------------------------------------------------------|-------------------------------------------------------------------------------------------------|--------------|------------------------------------------------------------------------------------------|
| [OfX](https://www.nuget.org/packages/OfX/) | OfX core | 8.0, 9.0 | This Document |
| [OfX-EFCore](https://www.nuget.org/packages/OfX-EFCore/) | This is the OfX extension package using EntityFramework to fetch data | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.EntityFrameworkCore/README.md) |
| [OfX-gRPC](https://www.nuget.org/packages/OfX-gRPC/) | OfX.gRPC is an extension package for OfX that leverages gRPC for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.Grpc/README.md) |
| [OfX-Nats](https://www.nuget.org/packages/OfX-Nats/) | OfX-Nats is an extension package for OfX that leverages Nats for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.Nats/README.md) |
| Package Name | Description | .NET Version | Document |
|--------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|--------------|------------------------------------------------------------------------------------------|
| [OfX](https://www.nuget.org/packages/OfX/) | OfX core | 8.0, 9.0 | This Document |
| [OfX-EFCore](https://www.nuget.org/packages/OfX-EFCore/) | This is the OfX extension package using EntityFramework to fetch data | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.EntityFrameworkCore/README.md) |
| [OfX-gRPC](https://www.nuget.org/packages/OfX-gRPC/) | OfX.gRPC is an extension package for OfX that leverages gRPC for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.Grpc/README.md) |
| [OfX-Nats](https://www.nuget.org/packages/OfX-Nats/) | OfX-Nats is an extension package for OfX that leverages Nats for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.Nats/README.md) |
| [OfX-RabbitMq](https://www.nuget.org/packages/OfX-RabbitMq/) | OfX-RabbitMq is an extension package for OfX that leverages RabbitMq for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.RabbitMq/README.md) |
---
2 changes: 1 addition & 1 deletion RealTest/Kernel/Kernel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\OfX.EntityFrameworkCore\OfX.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\src\OfX.Nats\OfX.Nats.csproj" />
<ProjectReference Include="..\..\src\OfX.RabbitMq\OfX.RabbitMq.csproj" />
<ProjectReference Include="..\..\src\OfX\OfX.csproj" />
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions RealTest/Service1.Contract/Responses/MemberResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ public class MemberResponse
public string Id { get; set; }
public string UserId { get; set; }
[UserOf(nameof(UserId))] public string UserName { get; set; }

[UserOf(nameof(UserId), Expression = "Email")]
public string UserEmail { get; set; }

[UserOf(nameof(UserId), Expression = "ProvinceId")]
public string ProvinceId { get; set; }

[ProvinceOf(nameof(ProvinceId), Order = 1)]
public string ProvinceName { get; set; }

[ProvinceOf(nameof(ProvinceId), Expression = "Country.Name", Order = 1)]
public string CountryName { get; set; }
}
5 changes: 2 additions & 3 deletions RealTest/Service1/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Kernel;
using OfX.Extensions;
using OfX.Nats.Extensions;
using OfX.RabbitMq.Extensions;

var builder = WebApplication.CreateBuilder(args);

Expand All @@ -10,8 +10,7 @@
builder.Services.AddOfX(cfg =>
{
cfg.AddAttributesContainNamespaces(typeof(IKernelAssemblyMarker).Assembly);
cfg.AddNats(config => config.Url("nats://localhost:4222"));

cfg.AddRabbitMq(config => config.Host("localhost", "/"));
});

builder.Services.AddControllers();
Expand Down
6 changes: 3 additions & 3 deletions RealTest/Service2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
using Microsoft.EntityFrameworkCore;
using OfX.EntityFrameworkCore.Extensions;
using OfX.Extensions;
using OfX.Nats.Extensions;
using OfX.RabbitMq.Extensions;
using WorkerService1;
using WorkerService1.Contexts;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOfX(cfg =>
{
cfg.AddAttributesContainNamespaces(typeof(IKernelAssemblyMarker).Assembly);
cfg.AddNats(config => config.Url("nats://localhost:4222"));
cfg.AddRabbitMq(config => config.Host("localhost", "/"));
})
.AddOfXEFCore(cfg =>
{
Expand All @@ -30,5 +30,5 @@
}, 128);

var app = builder.Build();
app.StartNatsListeningAsync();
app.StartRabbitMqListeningAsync();
app.Run();
10 changes: 7 additions & 3 deletions RealTest/Service3/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
using Microsoft.EntityFrameworkCore;
using OfX.EntityFrameworkCore.Extensions;
using OfX.Extensions;
using OfX.Nats.Extensions;
using OfX.RabbitMq.Extensions;
using Service3Api;
using Service3Api.Contexts;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOfX(cfg =>
{
cfg.AddAttributesContainNamespaces(typeof(IKernelAssemblyMarker).Assembly);
cfg.AddNats(config => config.Url("nats://localhost:4222"));
cfg.AddRabbitMq(config => config.Host("localhost", "/", 5672, c =>
{
c.UserName("SomeUserName");
c.Password("SomePassword");
}));
})
.AddOfXEFCore(cfg =>
{
Expand All @@ -29,5 +33,5 @@
}, 128);

var app = builder.Build();
app.StartNatsListeningAsync();
app.StartRabbitMqListeningAsync();
app.Run();
2 changes: 1 addition & 1 deletion src/OfX.EntityFrameworkCore/OfX.EntityFrameworkCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
<LangVersion>default</LangVersion>
<Version>3.1.7</Version>
<Version>3.1.8</Version>
<Authors>Quy Vu</Authors>
<PackageId>OfX-EFCore</PackageId>
<Description>OfX extension. Use EntityFramework as Data Querying</Description>
Expand Down
13 changes: 7 additions & 6 deletions src/OfX.EntityFrameworkCore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ That all! Let go to the moon!

Note: In this release, Id is exclusively supported as a string. But hold tight—I'm gearing up to blow your mind with the next update! Stay tuned!

| Package Name | Description | .NET Version | Document |
|----------------------------------------------------------|-------------------------------------------------------------------------------------------------|--------------|---------------------------------------------------------------------------|
| [OfX](https://www.nuget.org/packages/OfX/) | OfX core | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/README.md) |
| [OfX-EFCore](https://www.nuget.org/packages/OfX-EFCore/) | This is the OfX extension package using EntityFramework to fetch data | 8.0, 9.0 | This Document |
| [OfX-gRPC](https://www.nuget.org/packages/OfX-gRPC/) | OfX.gRPC is an extension package for OfX that leverages gRPC for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.Grpc/README.md) |
| [OfX-Nats](https://www.nuget.org/packages/OfX-Nats/) | OfX-Nats is an extension package for OfX that leverages Nats for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.Nats/README.md) |
| Package Name | Description | .NET Version | Document |
|--------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|--------------|-------------------------------------------------------------------------------|
| [OfX](https://www.nuget.org/packages/OfX/) | OfX core | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/README.md) |
| [OfX-EFCore](https://www.nuget.org/packages/OfX-EFCore/) | This is the OfX extension package using EntityFramework to fetch data | 8.0, 9.0 | This Document |
| [OfX-gRPC](https://www.nuget.org/packages/OfX-gRPC/) | OfX.gRPC is an extension package for OfX that leverages gRPC for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.Grpc/README.md) |
| [OfX-Nats](https://www.nuget.org/packages/OfX-Nats/) | OfX-Nats is an extension package for OfX that leverages Nats for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.Nats/README.md) |
| [OfX-RabbitMq](https://www.nuget.org/packages/OfX-RabbitMq/) | OfX-RabbitMq is an extension package for OfX that leverages RabbitMq for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.RabbitMq/README.md) |
---
2 changes: 1 addition & 1 deletion src/OfX.Grpc/OfX.Grpc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
<LangVersion>default</LangVersion>
<Version>3.1.7</Version>
<Version>3.1.8</Version>
<Authors>Quy Vu</Authors>
<PackageId>OfX-gRPC</PackageId>
<Description>OfX extension. Use gRPC as Data transporting</Description>
Expand Down
14 changes: 7 additions & 7 deletions src/OfX.Grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ For Client:
builder.Services.AddOfX(cfg =>
{
cfg.AddContractsContainNamespaces(typeof(SomeContractAssemblyMarker).Assembly);
cfg.AddHandlersFromNamespaceContaining<SomeHandlerAssemblyMarker>();
cfg.AddGrpcClients(config => config
.AddGrpcHostWithOfXAttributes("http://localhost:5001", [typeof(UserOfAttribute)])
.AddGrpcHostWithOfXAttributes("http://localhost:5002", [typeof(CountryOfAttribute), typeof(ProvinceOfAttribute)...])
Expand All @@ -67,10 +66,11 @@ After installing the package OfX-gRPC, you can use the extension method `AddGrpc
That All, enjoy your moment!


| Package Name | Description | .NET Version | Document |
|----------------------------------------------------------|-------------------------------------------------------------------------------------------------|--------------|------------------------------------------------------------------------------------------|
| [OfX](https://www.nuget.org/packages/OfX/) | OfX core | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/README.md) |
| [OfX-EFCore](https://www.nuget.org/packages/OfX-EFCore/) | This is the OfX extension package using EntityFramework to fetch data | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.EntityFrameworkCore/README.md) |
| [OfX-gRPC](https://www.nuget.org/packages/OfX-gRPC/) | OfX.gRPC is an extension package for OfX that leverages gRPC for efficient data transportation. | 8.0, 9.0 | This Document |
| [OfX-Nats](https://www.nuget.org/packages/OfX-Nats/) | OfX-Nats is an extension package for OfX that leverages Nats for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.Nats/README.md) |
| Package Name | Description | .NET Version | Document |
|--------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|--------------|------------------------------------------------------------------------------------------|
| [OfX](https://www.nuget.org/packages/OfX/) | OfX core | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/README.md) |
| [OfX-EFCore](https://www.nuget.org/packages/OfX-EFCore/) | This is the OfX extension package using EntityFramework to fetch data | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.EntityFrameworkCore/README.md) |
| [OfX-gRPC](https://www.nuget.org/packages/OfX-gRPC/) | OfX.gRPC is an extension package for OfX that leverages gRPC for efficient data transportation. | 8.0, 9.0 | This Document |
| [OfX-Nats](https://www.nuget.org/packages/OfX-Nats/) | OfX-Nats is an extension package for OfX that leverages Nats for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.Nats/README.md) |
| [OfX-RabbitMq](https://www.nuget.org/packages/OfX-RabbitMq/) | OfX-RabbitMq is an extension package for OfX that leverages RabbitMq for efficient data transportation. | 8.0, 9.0 | [ReadMe](https://github.com/quyvu01/OfX/blob/main/src/OfX.RabbitMq/README.md) |
---
5 changes: 2 additions & 3 deletions src/OfX.Nats/Abstractions/IOfXNatsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public interface IOfXNatsClient<TAttribute> : IMappableRequestHandler<TAttribute
async Task<ItemsResponse<OfXDataResponse>> IMappableRequestHandler<TAttribute>.RequestAsync(
RequestContext<TAttribute> context)
{
var natRequesterService = ServiceProvider.GetRequiredService<INatsRequester<TAttribute>>();
var result = await natRequesterService.RequestAsync(context);
return result;
var natsRequester = ServiceProvider.GetRequiredService<INatsRequester<TAttribute>>();
return await natsRequester.RequestAsync(context);
}
}
1 change: 0 additions & 1 deletion src/OfX.Nats/Implementations/NatsRequester.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NATS.Client.Core;
using NATS.Net;
using OfX.Abstractions;
using OfX.Attributes;
using OfX.Extensions;
Expand Down
6 changes: 0 additions & 6 deletions src/OfX.Nats/Messages/NatsMessageReceived.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
namespace OfX.Nats.Messages;

internal class NatsMessageReceived
{
public Dictionary<string, string> Headers { get; set; }
public MessageRequestOf Query { get; set; }
}

internal class MessageRequestOf
{
public List<string> SelectorIds { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/OfX.Nats/OfX.Nats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
<LangVersion>default</LangVersion>
<Version>3.1.7</Version>
<Version>3.1.8</Version>
<Authors>Quy Vu</Authors>
<PackageId>OfX-Nats</PackageId>
<Description>Nats.io extension. Use Nats as Data transporting</Description>
Expand Down
Loading

0 comments on commit 3ef2dde

Please sign in to comment.