PostgresSyncLogRepository
Repository for sync log operations in PostgreSQL. Implements spec Section 7 (Unified Change Log) for Postgres.
public static class PostgresSyncLogRepository
Methods
FetchChanges(NpgsqlConnection, long, int)
public static Result<IReadOnlyList<SyncLogEntry>, SyncError> FetchChanges(NpgsqlConnection connection, long fromVersion, int limit)
Fetches changes from _sync_log since the specified version.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
NpgsqlConnection |
PostgreSQL connection. |
fromVersion |
Int64 |
Version to start from (exclusive). |
limit |
Int32 |
Maximum number of changes to return. |
Returns: SyncError> - List of changes or database error.
Insert(NpgsqlConnection, SyncLogEntry)
public static Result<bool, SyncError> Insert(NpgsqlConnection connection, SyncLogEntry entry)
Inserts a change into _sync_log.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
NpgsqlConnection |
PostgreSQL connection. |
entry |
SyncLogEntry |
Entry to insert. |
Returns: SyncError> - Success or database error.
GetLastServerVersion(NpgsqlConnection)
public static Result<long, SyncError> GetLastServerVersion(NpgsqlConnection connection)
Gets the last server version from _sync_state.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
NpgsqlConnection |
PostgreSQL connection. |
Returns: SyncError> - Last server version or database error.
GetMaxVersion(NpgsqlConnection)
public static Result<long, SyncError> GetMaxVersion(NpgsqlConnection connection)
Gets the maximum version in _sync_log.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
NpgsqlConnection |
PostgreSQL connection. |
Returns: SyncError> - Max version or database error.
UpdateLastServerVersion(NpgsqlConnection, long)
public static Result<bool, SyncError> UpdateLastServerVersion(NpgsqlConnection connection, long version)
Updates the last server version in _sync_state.
Parameters:
| Name | Type | Description |
|---|---|---|
connection |
NpgsqlConnection |
PostgreSQL connection. |
version |
Int64 |
Version to set. |
Returns: SyncError> - Success or database error.