namespace NATS.Server.JetStream.Storage;

// StoreCipher and StoreCompression are defined in AeadEncryptor.cs (Task 4).

// Go: server/filestore.go:55
/// <summary>
/// Configuration for the file-based block store engine.
/// Passed to the FileStore constructor and controls directory layout, block sizing,
/// cache eviction, background sync, encryption, and compression.
/// Mirrors Go's FileStoreConfig struct (filestore.go:55).
/// </summary>
public sealed class FileStoreConfig
{
    // Go: FileStoreConfig.StoreDir — root directory for all stream block files
    public string StoreDir { get; set; } = string.Empty;

    // Go: FileStoreConfig.BlockSize — maximum bytes per message block file.
    //     0 means use the engine default (currently 8 MiB in Go).
    public ulong BlockSize { get; set; }

    // Go: FileStoreConfig.CacheExpire — how long to keep a loaded block in memory
    //     after the last read before evicting. Default: 10 seconds.
    public TimeSpan CacheExpire { get; set; } = TimeSpan.FromSeconds(10);

    // Go: FileStoreConfig.SubjectStateExpire — how long to keep per-subject state cached
    //     on an idle message block. Zero means use CacheExpire.
    public TimeSpan SubjectStateExpire { get; set; }

    // Go: FileStoreConfig.SyncInterval — interval at which dirty blocks are fsynced.
    //     Default: 2 minutes.
    public TimeSpan SyncInterval { get; set; } = TimeSpan.FromMinutes(2);

    // Go: FileStoreConfig.SyncAlways — when true every write is immediately fsynced
    public bool SyncAlways { get; set; }

    // Go: FileStoreConfig.AsyncFlush — when true write operations are batched and
    //     flushed asynchronously for higher throughput
    public bool AsyncFlush { get; set; }

    // Go: FileStoreConfig.Cipher — cipher used for at-rest encryption; NoCipher disables it
    public StoreCipher Cipher { get; set; } = StoreCipher.NoCipher;

    // Go: FileStoreConfig.Compression — compression algorithm applied to block data
    public StoreCompression Compression { get; set; } = StoreCompression.NoCompression;
}
