feat(batch27): implement jetstream engine state and account enable core
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user