🧱 Add stream (NATS) message queue infra
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.7" />
|
||||
<PackageReference Include="NATS.Client.Core" Version="2.6.6" />
|
||||
<PackageReference Include="NetTopologySuite" Version="2.6.0" />
|
||||
<PackageReference Include="NodaTime" Version="3.2.2" />
|
||||
<PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.2.0" />
|
||||
|
9
DysonNetwork.Shared/Stream/AccountEvent.cs
Normal file
9
DysonNetwork.Shared/Stream/AccountEvent.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using NodaTime;
|
||||
|
||||
namespace DysonNetwork.Shared.Stream;
|
||||
|
||||
public class AccountDeletedEvent
|
||||
{
|
||||
public Guid AccountId { get; set; } = Guid.NewGuid();
|
||||
public Instant DeletedAt { get; set; } = SystemClock.Instance.GetCurrentInstant();
|
||||
}
|
21
DysonNetwork.Shared/Stream/Connector.cs
Normal file
21
DysonNetwork.Shared/Stream/Connector.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NATS.Client.Core;
|
||||
|
||||
namespace DysonNetwork.Shared.Stream;
|
||||
|
||||
public static class Connector
|
||||
{
|
||||
public static IServiceCollection AddStreamConnection(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var connectionString = configuration.GetConnectionString("Stream");
|
||||
if (connectionString is null)
|
||||
throw new ArgumentNullException(nameof(connectionString));
|
||||
services.AddSingleton<INatsConnection>(_ => new NatsConnection(new NatsOpts()
|
||||
{
|
||||
Url = connectionString
|
||||
}));
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user