using System.Collections.Generic;
namespace CarpaNet.Jetstream;
///
/// Options for subscribing to a Jetstream event stream.
///
public sealed class JetstreamSubscribeOptions
{
///
/// Collection NSIDs to filter on. Supports prefix wildcards (e.g. "app.bsky.feed.*").
/// Max 100 entries.
///
public IReadOnlyList? WantedCollections { get; set; }
///
/// Repo DIDs to filter on. Max 10,000 entries.
///
public IReadOnlyList? WantedDids { get; set; }
///
/// Unix microseconds timestamp to resume playback from.
///
public long? Cursor { get; set; }
///
/// Maximum event payload size in bytes. Events exceeding this are dropped. Zero or null means no limit.
///
public int? MaxMessageSizeBytes { get; set; }
///
/// Enable zstd compression. Requires a zstd decoder with the Jetstream custom dictionary.
///
public bool Compress { get; set; }
///
/// Pause event delivery until the client sends an options_update message.
///
public bool RequireHello { get; set; }
internal IEnumerable> ToQueryParameters()
{
if (WantedCollections != null)
{
foreach (var collection in WantedCollections)
{
yield return new KeyValuePair("wantedCollections", collection);
}
}
if (WantedDids != null)
{
foreach (var did in WantedDids)
{
yield return new KeyValuePair("wantedDids", did);
}
}
if (Cursor.HasValue)
{
yield return new KeyValuePair("cursor", Cursor.Value.ToString());
}
if (MaxMessageSizeBytes.HasValue)
{
yield return new KeyValuePair("maxMessageSizeBytes", MaxMessageSizeBytes.Value.ToString());
}
if (Compress)
{
yield return new KeyValuePair("compress", "true");
}
if (RequireHello)
{
yield return new KeyValuePair("requireHello", "true");
}
}
}