141 lines
3.6 KiB
C#
141 lines
3.6 KiB
C#
using System;
|
|
using Svrnty.CQRS.Events.Subscriptions;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Svrnty.CQRS.Events.Management;
|
|
|
|
/// <summary>
|
|
/// Information about an event stream for management API responses.
|
|
/// </summary>
|
|
public sealed record StreamInfo
|
|
{
|
|
/// <summary>
|
|
/// Name of the stream.
|
|
/// </summary>
|
|
public required string Name { get; init; }
|
|
|
|
/// <summary>
|
|
/// Stream type (Ephemeral or Persistent).
|
|
/// </summary>
|
|
public required string Type { get; init; }
|
|
|
|
/// <summary>
|
|
/// Delivery semantics (AtMostOnce, AtLeastOnce, ExactlyOnce).
|
|
/// </summary>
|
|
public required string DeliverySemantics { get; init; }
|
|
|
|
/// <summary>
|
|
/// Stream scope (Internal or CrossService).
|
|
/// </summary>
|
|
public required string Scope { get; init; }
|
|
|
|
/// <summary>
|
|
/// Current length of the stream (total events).
|
|
/// </summary>
|
|
public long Length { get; init; }
|
|
|
|
/// <summary>
|
|
/// Number of subscriptions on this stream.
|
|
/// </summary>
|
|
public int SubscriptionCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// List of subscription IDs.
|
|
/// </summary>
|
|
public List<string> Subscriptions { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Information about a subscription for management API responses.
|
|
/// </summary>
|
|
public sealed record SubscriptionInfo
|
|
{
|
|
/// <summary>
|
|
/// Unique subscription identifier.
|
|
/// </summary>
|
|
public required string SubscriptionId { get; init; }
|
|
|
|
/// <summary>
|
|
/// Name of the stream this subscription consumes from.
|
|
/// </summary>
|
|
public required string StreamName { get; init; }
|
|
|
|
/// <summary>
|
|
/// Subscription mode (Broadcast, Exclusive, ConsumerGroup).
|
|
/// </summary>
|
|
public required string Mode { get; init; }
|
|
|
|
/// <summary>
|
|
/// Whether the subscription is active.
|
|
/// </summary>
|
|
public bool IsActive { get; init; }
|
|
|
|
/// <summary>
|
|
/// When the subscription was created.
|
|
/// </summary>
|
|
public DateTimeOffset CreatedAt { get; init; }
|
|
|
|
/// <summary>
|
|
/// Visibility timeout for in-flight events.
|
|
/// </summary>
|
|
public TimeSpan VisibilityTimeout { get; init; }
|
|
|
|
/// <summary>
|
|
/// Whether automatic upcasting is enabled.
|
|
/// </summary>
|
|
public bool EnableUpcasting { get; init; }
|
|
|
|
/// <summary>
|
|
/// Target event version for upcasting (null = latest).
|
|
/// </summary>
|
|
public int? TargetEventVersion { get; init; }
|
|
|
|
/// <summary>
|
|
/// Optional description of the subscription.
|
|
/// </summary>
|
|
public string? Description { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Information about a consumer for management API responses.
|
|
/// </summary>
|
|
public sealed record ConsumerInfo
|
|
{
|
|
/// <summary>
|
|
/// Consumer ID.
|
|
/// </summary>
|
|
public required string ConsumerId { get; init; }
|
|
|
|
/// <summary>
|
|
/// Current offset (position in stream).
|
|
/// </summary>
|
|
public long Offset { get; init; }
|
|
|
|
/// <summary>
|
|
/// Number of events the consumer is behind the stream head.
|
|
/// </summary>
|
|
public long Lag { get; init; }
|
|
|
|
/// <summary>
|
|
/// Last time the consumer updated its offset.
|
|
/// </summary>
|
|
public DateTimeOffset LastUpdated { get; init; }
|
|
|
|
/// <summary>
|
|
/// Whether the consumer appears to be stalled (no progress).
|
|
/// </summary>
|
|
public bool IsStalled { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Request to reset a consumer's offset.
|
|
/// </summary>
|
|
public sealed record ResetOffsetRequest
|
|
{
|
|
/// <summary>
|
|
/// The new offset to set. Use 0 to reset to the beginning.
|
|
/// Use -1 to set to the end (latest).
|
|
/// </summary>
|
|
public long NewOffset { get; init; }
|
|
}
|