logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class HttpStructuredStore

    IStructuredStore implementation backed by a remote HTTP structured-store service. See WireProtocol.md next to this file for the full wire shape.

    Inheritance
    object
    HttpStructuredStore
    Implements
    IStructuredStore
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.StructuredPersistence.Infrastructure.Http
    Assembly: Serenity.StructuredPersistence.Http.dll
    Syntax
    public class HttpStructuredStore : IStructuredStore
    Remarks

    Failure semantics are LOUD, unlike an on-device backend: a non-2xx response or a transport-level failure throws a PersistenceStoreException after logging a warning (error-response bodies are truncated to a diagnostic-safe length in both). HealthCheckAsync(CancellationToken) is the one exception — it never throws, returning false on any failure, including when its cancellation token is already cancelled (intentional: health probes report status, they do not fail). A caller-cancelled token always surfaces as an UNWRAPPED OperationCanceledException, never as a PersistenceStoreException, and is never retried. QueryAsync(StoreTable, StructuredQuery, CancellationToken) and CountAsync(StoreTable, IReadOnlyList<FieldFilter>, IReadOnlyList<string>, CancellationToken) are treated as idempotent reads and retry once, after a short fixed delay, on a transport-level failure; every other operation (insert/upsert/delete/trim/schema) never retries.

    Timeout discipline: each call is bounded end-to-end (headers AND body) by TimeoutSeconds via a linked cancellation token. The shared System.Net.Http.HttpClient's own System.Net.Http.HttpClient.Timeout is never touched, since callers may share one client instance across stores with different timeouts.

    Constructors

    HttpStructuredStore(HttpClient, HttpStructuredStoreConfiguration, ILogService)

    Initializes a new instance of the HttpStructuredStore class.

    Declaration
    public HttpStructuredStore(HttpClient httpClient, HttpStructuredStoreConfiguration configuration, ILogService logService)
    Parameters
    Type Name Description
    HttpClient httpClient

    The shared System.Net.Http.HttpClient instance used for every request. Callers must never construct a new System.Net.Http.HttpClient per store — share one instance across the application's lifetime.

    HttpStructuredStoreConfiguration configuration

    The remote service configuration.

    ILogService logService

    Logging service used to report retries and failures. May be null.

    Properties

    Namespace

    Declaration
    public string Namespace { get; }
    Property Value
    Type Description
    string

    Methods

    CountAsync(StoreTable, IReadOnlyList<FieldFilter>, IReadOnlyList<string>, CancellationToken)

    Declaration
    public Task<long> CountAsync(StoreTable table, IReadOnlyList<FieldFilter> filters, IReadOnlyList<string> distinctBy, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StoreTable table
    IReadOnlyList<FieldFilter> filters
    IReadOnlyList<string> distinctBy
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<long>

    DeleteByQueryAsync(StoreTable, IReadOnlyList<FieldFilter>, CancellationToken)

    Declaration
    public Task DeleteByQueryAsync(StoreTable table, IReadOnlyList<FieldFilter> filters, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StoreTable table
    IReadOnlyList<FieldFilter> filters
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    EnsureSchemaAsync(StructuredTableSchema, CancellationToken)

    Declaration
    public Task EnsureSchemaAsync(StructuredTableSchema schema, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StructuredTableSchema schema
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    HealthCheckAsync(CancellationToken)

    Declaration
    public Task<bool> HealthCheckAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<bool>
    Remarks

    Never throws: any failure — non-2xx, transport error, timeout, or an already-cancelled cancellationToken — returns false.

    InsertAsync(StoreTable, StructuredRecord, StructuredTrim, CancellationToken)

    Declaration
    public Task InsertAsync(StoreTable table, StructuredRecord record, StructuredTrim trim, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StoreTable table
    StructuredRecord record
    StructuredTrim trim
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    QueryAsync(StoreTable, StructuredQuery, CancellationToken)

    Declaration
    public Task<IReadOnlyList<StructuredRecord>> QueryAsync(StoreTable table, StructuredQuery query, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StoreTable table
    StructuredQuery query
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<IReadOnlyList<StructuredRecord>>

    TrimBeyondAsync(StoreTable, IReadOnlyList<FieldFilter>, IReadOnlyList<OrderField>, int, CancellationToken)

    Declaration
    public Task TrimBeyondAsync(StoreTable table, IReadOnlyList<FieldFilter> scopeFilters, IReadOnlyList<OrderField> ordering, int keepCount, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StoreTable table
    IReadOnlyList<FieldFilter> scopeFilters
    IReadOnlyList<OrderField> ordering
    int keepCount
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    UpsertIfBetterAsync(StoreTable, StructuredRecord, IReadOnlyList<string>, string, StructuredSortDirection, StructuredTrim, CancellationToken)

    Declaration
    public Task UpsertIfBetterAsync(StoreTable table, StructuredRecord record, IReadOnlyList<string> keyFields, string comparisonField, StructuredSortDirection betterDirection, StructuredTrim trim, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StoreTable table
    StructuredRecord record
    IReadOnlyList<string> keyFields
    string comparisonField
    StructuredSortDirection betterDirection
    StructuredTrim trim
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    Implements

    IStructuredStore
    In this article
    © 2026 Serenity. All Rights Reserved