Class LogicalReplicationConnectionExtensions
This API is for internal use and for implementing logical replication plugins. It is not meant to be consumed in common Npgsql usage scenarios.
Inherited Members
Namespace: Npgsql.Replication.Internal
Assembly: Npgsql.dll
Syntax
public static class LogicalReplicationConnectionExtensions
Methods
CreateLogicalReplicationSlot(LogicalReplicationConnection, String, String, Boolean, Nullable<LogicalSlotSnapshotInitMode>, CancellationToken)
This API is for internal use and for implementing logical replication plugins. It is not meant to be consumed in common Npgsql usage scenarios.
Declaration
public static Task<ReplicationSlotOptions> CreateLogicalReplicationSlot(this LogicalReplicationConnection connection, string slotName, string outputPlugin, bool isTemporary = false, LogicalSlotSnapshotInitMode? slotSnapshotInitMode = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
LogicalReplicationConnection | connection | The LogicalReplicationConnection to use for creating the replication slot |
String | slotName | The name of the slot to create. Must be a valid replication slot name (see https://www.postgresql.org/docs/current/warm-standby.html#STREAMING-REPLICATION-SLOTS-MANIPULATION). |
String | outputPlugin | The name of the output plugin used for logical decoding (see https://www.postgresql.org/docs/current/logicaldecoding-output-plugin.html). |
Boolean | isTemporary | true if this replication slot shall be temporary one; otherwise false. Temporary slots are not saved to disk and are automatically dropped on error or when the session has finished. |
Nullable<LogicalSlotSnapshotInitMode> | slotSnapshotInitMode | A LogicalSlotSnapshotInitMode to specify what to do with the snapshot created during logical slot initialization. Export, which is also the default, will export the snapshot for use in other sessions. This option can't be used inside a transaction. Use will use the snapshot for the current transaction executing the command. This option must be used in a transaction, and Use must be the first command run in that transaction. Finally, NoExport will just use the snapshot for logical decoding as normal but won't do anything else with it. |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is None. |
Returns
Type | Description |
---|---|
Task<ReplicationSlotOptions> | A Task<TResult> representing a ReplicationSlotOptions class that can be used to initialize instances of ReplicationSlot subclasses. |
Remarks
Creates a new replication slot and returns information about the newly-created slot.
StartLogicalReplication(LogicalReplicationConnection, LogicalReplicationSlot, CancellationToken, Nullable<NpgsqlLogSequenceNumber>, IEnumerable<KeyValuePair<String, String>>, Boolean)
Instructs the server to start streaming the WAL for logical replication, starting at WAL location
walLocation
or at the slot's consistent point if walLocation
isn't specified.
The server can reply with an error, for example if the requested section of the WAL has already been recycled.
Declaration
public static IAsyncEnumerable<XLogDataMessage> StartLogicalReplication(this LogicalReplicationConnection connection, LogicalReplicationSlot slot, CancellationToken cancellationToken, NpgsqlLogSequenceNumber? walLocation = null, IEnumerable<KeyValuePair<string, string>> options = null, bool bypassingStream = false)
Parameters
Type | Name | Description |
---|---|---|
LogicalReplicationConnection | connection | The LogicalReplicationConnection to use for starting replication |
LogicalReplicationSlot | 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 monitor for stopping the replication. |
Nullable<NpgsqlLogSequenceNumber> | walLocation | The WAL location to begin streaming at. |
IEnumerable<KeyValuePair<String, String>> | options | The collection of options passed to the slot's logical decoding plugin. |
Boolean | bypassingStream | Whether the plugin will be bypassing Data and reading directly from the buffer. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<XLogDataMessage> | A Task<TResult> representing an IAsyncEnumerable<T> that can be used to stream WAL entries in form of XLogDataMessage instances. |