Class PhysicalReplicationConnection
Represents a physical replication connection to a PostgreSQL server.
Inherited Members
Namespace: Npgsql.Replication
Assembly: Npgsql.dll
Syntax
public sealed class PhysicalReplicationConnection : ReplicationConnection
Constructors
| Improve this Doc View SourcePhysicalReplicationConnection()
Initializes a new instance of PhysicalReplicationConnection.
Declaration
public PhysicalReplicationConnection()
PhysicalReplicationConnection(string?)
Initializes a new instance of PhysicalReplicationConnection with the given connection string.
Declaration
public PhysicalReplicationConnection(string? connectionString)
Parameters
Type | Name | Description |
---|---|---|
string? | connectionString | The connection used to open the PostgreSQL database. |
Methods
| Improve this Doc View SourceCreateReplicationSlot(string, bool, bool, CancellationToken)
Creates a PhysicalReplicationSlot that wraps a PostgreSQL physical replication slot and can be used to start physical streaming replication
Declaration
public Task<PhysicalReplicationSlot> CreateReplicationSlot(string slotName, bool isTemporary = false, bool reserveWal = false, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
string | slotName | The name of the slot to create. Must be a valid replication slot name (see Section 26.2.6.1). |
bool | isTemporary | true if this replication slot shall be a temporary one; otherwise false. Temporary slots are not saved to disk and are automatically dropped on error or when the session has finished. |
bool | reserveWal | If this is set to true this physical replication slot reserves WAL immediately. Otherwise, WAL is only reserved upon connection from a streaming replication client. |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is |
Returns
Type | Description |
---|---|
Task<><PhysicalReplicationSlot> | A |
ReadReplicationSlot(string, CancellationToken)
Read some information associated to a replication slot.
Declaration
public Task<PhysicalReplicationSlot?> ReadReplicationSlot(string slotName, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
string | slotName | The name of the slot to read. Must be a valid replication slot name |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is |
Returns
Type | Description |
---|---|
Task<><PhysicalReplicationSlot> | A |
StartReplication(PhysicalReplicationSlot, CancellationToken)
Instructs the server to start streaming the WAL for physical replication, starting at the WAL location
and timeline id specified in slot
. The server can reply with an error, for example
if the requested section of the WAL has already been recycled.
Declaration
public IAsyncEnumerable<XLogDataMessage> StartReplication(PhysicalReplicationSlot slot, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
PhysicalReplicationSlot | slot | The replication slot that will be updated as replication progresses so that the server
knows which WAL segments are still needed by the standby.
|
CancellationToken | cancellationToken | The token to be used for stopping the replication. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<><XLogDataMessage> | A |
Remarks
If the client requests a timeline that's not the latest but is part of the history of the server, the server will stream all the WAL on that timeline starting from the requested start point up to the point where the server switched to another timeline.
StartReplication(PhysicalReplicationSlot?, NpgsqlLogSequenceNumber, CancellationToken, uint)
Instructs the server to start streaming the WAL for physical replication, starting at WAL location
walLocation
. The server can reply with an error, for example if the requested
section of the WAL has already been recycled.
Declaration
public IAsyncEnumerable<XLogDataMessage> StartReplication(PhysicalReplicationSlot? slot, NpgsqlLogSequenceNumber walLocation, CancellationToken cancellationToken, uint timeline = null)
Parameters
Type | Name | Description |
---|---|---|
PhysicalReplicationSlot | slot | The replication slot that will be updated as replication progresses so that the server knows which WAL segments are still needed by the standby. |
NpgsqlLogSequenceNumber | walLocation | The WAL location to begin streaming at. |
CancellationToken | cancellationToken | The token to be used for stopping the replication. |
uint | timeline | Streaming starts on timeline tli. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<><XLogDataMessage> | A |
Remarks
If the client requests a timeline that's not the latest but is part of the history of the server, the server will stream all the WAL on that timeline starting from the requested start point up to the point where the server switched to another timeline.
StartReplication(NpgsqlLogSequenceNumber, CancellationToken, uint)
Instructs the server to start streaming the WAL for logical replication, starting at WAL location
walLocation
. The server can reply with an error, for example if the requested
section of WAL has already been recycled.
Declaration
public IAsyncEnumerable<XLogDataMessage> StartReplication(NpgsqlLogSequenceNumber walLocation, CancellationToken cancellationToken, uint timeline = null)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | walLocation | The WAL location to begin streaming at. |
CancellationToken | cancellationToken | The token to be used for stopping the replication. |
uint | timeline | Streaming starts on timeline tli. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<><XLogDataMessage> | A |
Remarks
If the client requests a timeline that's not the latest but is part of the history of the server, the server will stream all the WAL on that timeline starting from the requested start point up to the point where the server switched to another timeline.