🚚 Rename the Stream to Queue in internal code

This commit is contained in:
2025-12-25 19:11:39 +08:00
parent f792d43ab9
commit 0bc77b948c
13 changed files with 14 additions and 14 deletions

View 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();
}

View 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; }
}

View 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);
}
}
}

View 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; }
}