namespace ZB.MOM.NatsNet.Server;

public sealed partial class NatsServer
{
    internal int Replicas(StreamConfig? config)
    {
        if (config == null)
            return 1;

        return Math.Max(1, config.Replicas);
    }

    internal void SendStreamLostQuorumAdvisory(Account? account, string stream, string[]? peers = null)
    {
        _ = account;
        _ = peers;
        Noticef("JetStream stream lost quorum advisory for stream {0}", stream);
    }

    internal void SendStreamLeaderElectAdvisory(Account? account, string stream, string leader)
    {
        _ = account;
        Noticef("JetStream stream leader elect advisory for stream {0}, leader {1}", stream, leader);
    }

    internal bool RemoveStream(Account? account, string streamName)
    {
        if (account == null)
            return false;

        var (stream, _) = account.LookupStream(streamName);
        if (stream == null)
            return false;

        stream.Delete();
        return true;
    }
}
