feat(auth): add account import/export cycle detection and JetStream limits (E4+E5)
E4: AccountImportExport with DFS cycle detection for service imports, RemoveServiceImport/RemoveStreamImport, and ValidateImport authorization. E5: AccountLimits record with MaxStorage/MaxConsumers/MaxAckPending, TryReserveConsumer/ReleaseConsumer, TrackStorageDelta on Account. 20 new tests, all passing.
This commit is contained in:
32
src/NATS.Server/Auth/AccountLimits.cs
Normal file
32
src/NATS.Server/Auth/AccountLimits.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
// Per-account JetStream resource limits.
|
||||
// Go reference: accounts.go JetStreamAccountLimits struct.
|
||||
|
||||
namespace NATS.Server.Auth;
|
||||
|
||||
/// <summary>
|
||||
/// Per-account limits on JetStream resources: storage, streams, consumers, and ack pending.
|
||||
/// A value of 0 means unlimited for all fields.
|
||||
/// </summary>
|
||||
public sealed record AccountLimits
|
||||
{
|
||||
/// <summary>Maximum total storage in bytes (0 = unlimited).</summary>
|
||||
public long MaxStorage { get; init; }
|
||||
|
||||
/// <summary>Maximum number of streams (0 = unlimited).</summary>
|
||||
public int MaxStreams { get; init; }
|
||||
|
||||
/// <summary>Maximum number of consumers (0 = unlimited).</summary>
|
||||
public int MaxConsumers { get; init; }
|
||||
|
||||
/// <summary>Maximum pending ack count per consumer (0 = unlimited).</summary>
|
||||
public int MaxAckPending { get; init; }
|
||||
|
||||
/// <summary>Maximum memory-based storage in bytes (0 = unlimited).</summary>
|
||||
public long MaxMemoryStorage { get; init; }
|
||||
|
||||
/// <summary>Maximum disk-based storage in bytes (0 = unlimited).</summary>
|
||||
public long MaxDiskStorage { get; init; }
|
||||
|
||||
/// <summary>Default instance with all limits set to unlimited (0).</summary>
|
||||
public static AccountLimits Unlimited { get; } = new();
|
||||
}
|
||||
Reference in New Issue
Block a user