feat(batch27): implement jetstream engine state and account enable core

This commit is contained in:
Joseph Doherty
2026-02-28 21:01:11 -05:00
parent 4b7fac7957
commit 12b8c9b4c5
4 changed files with 370 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
namespace ZB.MOM.NatsNet.Server;
internal sealed class JetStreamEngine(JetStream state)
{
private readonly JetStream _state = state;
internal void SetStarted()
{
_state.Lock.EnterWriteLock();
try
{
_state.Started = DateTime.UtcNow;
}
finally
{
_state.Lock.ExitWriteLock();
}
}
internal bool IsEnabled() => Interlocked.CompareExchange(ref _state.Disabled, 0, 0) == 0;
internal void SetJetStreamStandAlone(bool isStandAlone)
{
_state.Lock.EnterWriteLock();
try
{
_state.StandAlone = isStandAlone;
}
finally
{
_state.Lock.ExitWriteLock();
}
}
internal bool IsShuttingDown()
{
_state.Lock.EnterReadLock();
try
{
return _state.ShuttingDown;
}
finally
{
_state.Lock.ExitReadLock();
}
}
}