Path: redb-route/redb.Route.Firebase/Firestore/FirestoreEndpointOptions.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Firebase/Firestore/FirestoreEndpointOptions.cs
----
using redb.Route.Core;
namespace redb.Route.Firebase;
///
/// Endpoint options for the Firestore component.
/// Supports both producer (CRUD/Query) and consumer (realtime listener / polling) modes.
///
public sealed class FirestoreEndpointOptions : EndpointOptions
{
// ── Auth ──
/// Path to the Firebase service-account JSON file.
public string? CredentialPath { get; set; }
/// Firebase/GCP project ID.
public string? ProjectId { get; set; }
/// Firestore database id for multi-database projects (default: (default)).
public string? DatabaseId { get; set; }
/// Named reference from the registry.
[RegistryReference(typeof(IFirebaseCredentialProvider))]
public string? ConnectionFactory { get; set; }
// ── Operation ──
/// Producer operation type. Default: .
public FirestoreOperationType Operation { get; set; } = FirestoreOperationType.Set;
// ── Document targeting ──
/// Document ID. Supports ${...} expressions.
public DynamicValue? DocumentId { get; set; }
// ── Query (consumer & producer Query) ──
/// Where filter: "status==pending" or "age>18". Multiple separated by ;.
public string? Where { get; set; }
/// Order by field: "createdAt" or "createdAt desc".
public string? OrderBy { get; set; }
/// Maximum number of documents to return.
public int? Limit { get; set; }
/// Pagination offset.
public int? Offset { get; set; }
// ── Set/Update/BatchWrite ──
/// Merge fields on Set instead of overwriting the entire document.
public bool Merge { get; set; }
///
/// BatchWrite: take the document id from this field of each item (the field itself is
/// not written to the document). Without it every item gets an auto-generated id.
///
public string? DocumentIdField { get; set; }
// ── Consumer: Realtime Listener ──
/// Use snapshot listener for realtime updates (default for consumer).
public bool Realtime { get; set; } = true;
///
/// Maximum number of document changes processed in parallel within one snapshot
/// (realtime mode). Default: 16.
///
public int MaxConcurrency { get; set; } = 16;
// ── Consumer: Polling (Realtime=false) ──
/// Poll interval (ms) for non-realtime mode. Default: 5000.
public int Delay { get; set; } = 5000;
/// Initial delay (ms) before first poll. Default: 1000.
public int InitialDelay { get; set; } = 1000;
// ── Serialization ──
/// Body as raw JSON string instead of Dictionary<string, object?>.
public bool RawJson { get; set; }
///
public override void Validate()
{
if (string.IsNullOrWhiteSpace(CredentialPath)
&& string.IsNullOrWhiteSpace(ConnectionFactory)
&& string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS"))
&& string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("FIRESTORE_EMULATOR_HOST")))
throw new ArgumentOutOfRangeException(nameof(CredentialPath),
"CredentialPath, ConnectionFactory, GOOGLE_APPLICATION_CREDENTIALS, or FIRESTORE_EMULATOR_HOST is required");
if (Delay < 100)
throw new ArgumentOutOfRangeException(nameof(Delay), "Delay must be >= 100ms");
if (MaxConcurrency < 1)
throw new ArgumentOutOfRangeException(nameof(MaxConcurrency), "MaxConcurrency must be >= 1");
if (Limit is not null && Limit < 1)
throw new ArgumentOutOfRangeException(nameof(Limit), "Limit must be >= 1");
}
}