Search Results for

    Show / Hide Table of Contents

    Class PhysicalReplicationConnection

    Represents a physical replication connection to a PostgreSQL server.

    Inheritance
    Object
    ReplicationConnection
    PhysicalReplicationConnection
    Implements
    IAsyncDisposable
    Inherited Members
    ReplicationConnection.ConnectionString
    ReplicationConnection.LastReceivedLsn
    ReplicationConnection.LastFlushedLsn
    ReplicationConnection.LastAppliedLsn
    ReplicationConnection.WalReceiverStatusInterval
    ReplicationConnection.WalReceiverTimeout
    ReplicationConnection.PostgreSqlVersion
    ReplicationConnection.ServerVersion
    ReplicationConnection.CommandTimeout
    ReplicationConnection.Encoding
    ReplicationConnection.ProcessID
    ReplicationConnection.Open(CancellationToken)
    ReplicationConnection.DisposeAsync()
    ReplicationConnection.IdentifySystem(CancellationToken)
    ReplicationConnection.Show(String, CancellationToken)
    ReplicationConnection.TimelineHistory(UInt32, CancellationToken)
    ReplicationConnection.SetReplicationStatus(NpgsqlLogSequenceNumber)
    ReplicationConnection.SendStatusUpdate(CancellationToken)
    ReplicationConnection.DropReplicationSlot(String, Boolean, CancellationToken)
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Npgsql.Replication
    Assembly: Npgsql.dll
    Syntax
    public sealed class PhysicalReplicationConnection : ReplicationConnection, IAsyncDisposable

    Constructors

    PhysicalReplicationConnection()

    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

    CreateReplicationSlot(String, Boolean, Boolean, 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 = default(CancellationToken))
    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).

    Boolean 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.

    Boolean 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 None.

    Returns
    Type Description
    Task<PhysicalReplicationSlot>

    A PhysicalReplicationSlot that wraps the newly-created replication slot.

    StartReplication(PhysicalReplicationSlot, NpgsqlLogSequenceNumber, CancellationToken, UInt32)

    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 = 0U)
    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.

    UInt32 timeline

    Streaming starts on timeline tli.

    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.

    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, UInt32)

    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 = 0U)
    Parameters
    Type Name Description
    NpgsqlLogSequenceNumber walLocation

    The WAL location to begin streaming at.

    CancellationToken cancellationToken

    The token to be used for stopping the replication.

    UInt32 timeline

    Streaming starts on timeline tli.

    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.

    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.

    Implements

    System.IAsyncDisposable
    In This Article
    Back to top © Copyright 2022 The Npgsql Development Team