Table of Contents

Class ReplicaSyncClient

Namespace
Honua.Sdk.Offline
Assembly
Honua.Sdk.Offline.dll

HTTP-based IReplicaSyncClient implementation targeting the GeoServices FeatureServer replica sync endpoints (createReplica, extractChanges, synchronizeReplica, unRegisterReplica).

public sealed class ReplicaSyncClient : IReplicaSyncClient
Inheritance
ReplicaSyncClient
Implements
Inherited Members

Constructors

ReplicaSyncClient(HttpClient)

Initializes a new instance of the ReplicaSyncClient class.

public ReplicaSyncClient(HttpClient httpClient)

Parameters

httpClient HttpClient

An HttpClient configured with the base address of the feature server.

Exceptions

ArgumentNullException

Thrown when httpClient is null.

Methods

CreateReplicaAsync(string, string, IReadOnlyList<int>?, CancellationToken)

Creates a new server-side replica for the specified service.

public Task<CreateReplicaResult> CreateReplicaAsync(string serviceId, string replicaName, IReadOnlyList<int>? layerIds = null, CancellationToken cancellationToken = default)

Parameters

serviceId string

The feature service identifier.

replicaName string

A name for the new replica.

layerIds IReadOnlyList<int>

Optional layer IDs to include. When null, all layers are included.

cancellationToken CancellationToken

A token to observe while waiting for the task to complete.

Returns

Task<CreateReplicaResult>

The created replica ID and initial server generation number.

ExtractChangesAsync(string, string, string?, CancellationToken)

Extracts feature changes (adds, updates, deletes) from the server, scoped to the changes that occurred after the supplied server generation.

public Task<ExtractChangesResult> ExtractChangesAsync(string serviceId, string replicaId, string? sinceServerGen, CancellationToken cancellationToken = default)

Parameters

serviceId string

The feature service identifier.

replicaId string

The replica ID obtained from CreateReplicaAsync(string, string, IReadOnlyList<int>?, CancellationToken).

sinceServerGen string

The server generation the local replica last applied, used as the lower bound ("since") for the extract. When null or whitespace, the server returns changes since its recorded replica cursor.

cancellationToken CancellationToken

A token to observe while waiting for the task to complete.

Returns

Task<ExtractChangesResult>

Layer-level changes, delivered generations, and transfer-limit metadata.

Remarks

The GeoServices replica protocol scopes extractChanges by the replica's last-known server generation. Pass the generation applied locally to extract its subsequent delta. Omitting it uses the server's recorded replica cursor, which may have advanced after a download that was not applied locally. The default implementation delegates to the generation-less overload for backward compatibility with existing implementations.

ExtractChangesAsync(string, string, CancellationToken)

Extracts feature changes (adds, updates, deletes) from the server's recorded replica cursor.

public Task<ExtractChangesResult> ExtractChangesAsync(string serviceId, string replicaId, CancellationToken cancellationToken = default)

Parameters

serviceId string

The feature service identifier.

replicaId string

The replica ID obtained from CreateReplicaAsync(string, string, IReadOnlyList<int>?, CancellationToken).

cancellationToken CancellationToken

A token to observe while waiting for the task to complete.

Returns

Task<ExtractChangesResult>

Layer-level changes, delivered generations, and transfer-limit metadata.

SynchronizeReplicaAsync(string, string, long, string, CancellationToken)

Synchronizes a replica using the generation already received and applied locally as the download lower bound (replicaServerGen).

public Task<SynchronizeResult> SynchronizeReplicaAsync(string serviceId, string replicaId, long receivedServerGen, string syncDirection = "download", CancellationToken cancellationToken = default)

Parameters

serviceId string

The feature service identifier.

replicaId string

The replica ID.

receivedServerGen long

The nonnegative server generation already applied locally.

syncDirection string

Sync direction (for example, "download").

cancellationToken CancellationToken

A token to observe while waiting for the task to complete.

Returns

Task<SynchronizeResult>

The replica ID, delivered generation, changes, and transfer-limit metadata.

Remarks

Pass the generation of the locally applied snapshot or preceding delivery. Apply the returned changes and save their generation together before continuing. If local application fails, retry with the preceding applied generation, even if the server cursor advanced. If ExceededTransferLimit is true, repeat after applying this window. This downloads intervening edits; it does not merely acknowledge an extract. Implementations that do not support an explicit generation throw rather than ignore it.

SynchronizeReplicaAsync(string, string, string, CancellationToken)

Synchronizes a replica and exposes any downloaded feature changes.

public Task<SynchronizeResult> SynchronizeReplicaAsync(string serviceId, string replicaId, string syncDirection = "download", CancellationToken cancellationToken = default)

Parameters

serviceId string

The feature service identifier.

replicaId string

The replica ID.

syncDirection string

Sync direction (for example, "download").

cancellationToken CancellationToken

A token to observe while waiting for the task to complete.

Returns

Task<SynchronizeResult>

The replica ID, delivered generation, changes, and transfer-limit metadata.

Remarks

Download synchronization advances the server's delivery cursor. It is not an acknowledgement that the caller applied the changes locally. Apply every returned change before persisting the returned generation; use the generation-aware overload to retry an unapplied delivery.

UnRegisterReplicaAsync(string, string, CancellationToken)

Unregisters a replica from the server, freeing server-side resources.

public Task UnRegisterReplicaAsync(string serviceId, string replicaId, CancellationToken cancellationToken = default)

Parameters

serviceId string

The feature service identifier.

replicaId string

The replica ID to unregister.

cancellationToken CancellationToken

A token to observe while waiting for the task to complete.

Returns

Task