Search Results for

    Show / Hide Table of Contents

    Class PhysicalReplicationConnection

    Represents a physical replication connection to a PostgreSQL server.

    Inheritance
    object
    ReplicationConnection
    PhysicalReplicationConnection
    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(uint, CancellationToken)
    ReplicationConnection.SetReplicationStatus(NpgsqlLogSequenceNumber)
    ReplicationConnection.SendStatusUpdate(CancellationToken)
    ReplicationConnection.DropReplicationSlot(string, bool, CancellationToken)
    Namespace: Npgsql.Replication
    Assembly: Npgsql.dll
    Syntax
    public sealed class PhysicalReplicationConnection : ReplicationConnection

    Constructors

    | Improve this Doc View Source

    PhysicalReplicationConnection()

    Initializes a new instance of PhysicalReplicationConnection.

    Declaration
    public PhysicalReplicationConnection()
    | Improve this Doc View Source

    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 Source

    CreateReplicationSlot(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 representing a PhysicalReplicationSlot that represents the newly-created replication slot.

    | Improve this Doc View Source

    ReadReplicationSlot(string, CancellationToken)

    Read some information associated to a replication slot. This command is currently only supported for physical replication slots.

    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 representing a PhysicalReplicationSlot or null if the replication slot does not exist.

    | Improve this Doc View Source

    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. The slot must contain a valid RestartLsn to be used for this overload.

    CancellationToken cancellationToken

    The token to be used for stopping the replication.

    Returns
    Type Description
    IAsyncEnumerable<><XLogDataMessage>

    A representing an 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.

    | Improve this Doc View Source

    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 representing an 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.

    | Improve this Doc View Source

    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 representing an 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.

    • Improve this Doc
    • View Source
    In This Article
    Back to top © Copyright 2023 The Npgsql Development Team