🚚 Rename the Stream to Queue in internal code
This commit is contained in:
21
DysonNetwork.Shared/Queue/AccountEvent.cs
Normal file
21
DysonNetwork.Shared/Queue/AccountEvent.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using DysonNetwork.Shared.Models;
|
||||
using NodaTime;
|
||||
|
||||
namespace DysonNetwork.Shared.Queue;
|
||||
|
||||
public class AccountDeletedEvent
|
||||
{
|
||||
public static string Type => "account_deleted";
|
||||
|
||||
public Guid AccountId { get; set; } = Guid.NewGuid();
|
||||
public Instant DeletedAt { get; set; } = SystemClock.Instance.GetCurrentInstant();
|
||||
}
|
||||
|
||||
public class AccountStatusUpdatedEvent
|
||||
{
|
||||
public static string Type => "account_status_updated";
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
public SnAccountStatus Status { get; set; } = new();
|
||||
public Instant UpdatedAt { get; set; } = SystemClock.Instance.GetCurrentInstant();
|
||||
}
|
||||
18
DysonNetwork.Shared/Queue/PaymentEvent.cs
Normal file
18
DysonNetwork.Shared/Queue/PaymentEvent.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace DysonNetwork.Shared.Queue;
|
||||
|
||||
public class PaymentOrderEvent : PaymentOrderEventBase
|
||||
{
|
||||
public Dictionary<string, object> Meta { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class PaymentOrderEventBase
|
||||
{
|
||||
public static string Type => "payment_orders";
|
||||
|
||||
public Guid OrderId { get; set; }
|
||||
public Guid WalletId { get; set; }
|
||||
public Guid AccountId { get; set; }
|
||||
public string? AppIdentifier { get; set; }
|
||||
public string? ProductIdentifier { get; set; }
|
||||
public int Status { get; set; }
|
||||
}
|
||||
23
DysonNetwork.Shared/Queue/QueueHelper.cs
Normal file
23
DysonNetwork.Shared/Queue/QueueHelper.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using NATS.Client.JetStream;
|
||||
using NATS.Client.JetStream.Models;
|
||||
|
||||
namespace DysonNetwork.Shared.Queue;
|
||||
|
||||
public static class QueueHelper
|
||||
{
|
||||
public static async Task<INatsJSStream> EnsureStreamCreated(
|
||||
this INatsJSContext context,
|
||||
string stream,
|
||||
ICollection<string>? subjects
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await context.CreateStreamAsync(new StreamConfig(stream, subjects ?? []));
|
||||
}
|
||||
catch (NatsJSException)
|
||||
{
|
||||
return await context.GetStreamAsync(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
34
DysonNetwork.Shared/Queue/WebSocketPacketEvent.cs
Normal file
34
DysonNetwork.Shared/Queue/WebSocketPacketEvent.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using NodaTime;
|
||||
|
||||
namespace DysonNetwork.Shared.Queue;
|
||||
|
||||
public class WebSocketPacketEvent
|
||||
{
|
||||
public static string Type => "websocket_msg";
|
||||
|
||||
public const string SubjectPrefix = "websocket_";
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
public string DeviceId { get; set; } = null!;
|
||||
public byte[] PacketBytes { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class WebSocketConnectedEvent
|
||||
{
|
||||
public static string Type => "websocket_connected";
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
public string DeviceId { get; set; } = null!;
|
||||
public Instant ConnectedAt { get; set; } = SystemClock.Instance.GetCurrentInstant();
|
||||
public bool IsOffline { get; set; } = false;
|
||||
}
|
||||
|
||||
public class WebSocketDisconnectedEvent
|
||||
{
|
||||
public static string Type => "websocket_disconnected";
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
public string DeviceId { get; set; } = null!;
|
||||
public Instant DisconnectedAt { get; set; } = SystemClock.Instance.GetCurrentInstant();
|
||||
public bool IsOffline { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user