Show / Hide Table of Contents

Class Replicator

An object that is responsible for the replication of data between two endpoints. The replication can set up to be pull only, push only, or both (i.e. pusher and puller are no longer separate) between a database and a URL or a database and another database on the same filesystem.

Inheritance
System.Object
Replicator
Implements
System.IDisposable
IChangeObservable<ReplicatorStatusChangedEventArgs>
IDocumentReplicatedObservable
IChangeObservableRemovable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: Couchbase.Lite.Sync
Assembly: Couchbase.Lite.dll
Syntax
public sealed class Replicator : IDisposable, IChangeObservable<ReplicatorStatusChangedEventArgs>, IDocumentReplicatedObservable, IChangeObservableRemovable

Constructors

| Improve this Doc View Source

Replicator(ReplicatorConfiguration)

Constructs a replicator based on the given ReplicatorConfiguration

Declaration
public Replicator(ReplicatorConfiguration config)
Parameters
Type Name Description
ReplicatorConfiguration config

The configuration to use to create the replicator

Properties

| Improve this Doc View Source

Config

Gets the configuration that was used to create this Replicator

Declaration
public ReplicatorConfiguration Config { get; }
Property Value
Type Description
ReplicatorConfiguration
Exceptions
Type Condition
CouchbaseLiteException

Thrown if the replicator configuration doesn't contain any collection.

| Improve this Doc View Source

ServerCertificate

This property allows the developer to know what the current server certificate is when using TLS communication. The developer could save the certificate and pin the certificate next time when setting up the replicator to provide an SSH type of authentication.

Declaration
public X509Certificate2 ServerCertificate { get; }
Property Value
Type Description
System.Security.Cryptography.X509Certificates.X509Certificate2
| Improve this Doc View Source

Status

Gets the current status of the Replicator

Declaration
public ReplicatorStatus Status { get; set; }
Property Value
Type Description
ReplicatorStatus

Methods

| Improve this Doc View Source

AddChangeListener(EventHandler<ReplicatorStatusChangedEventArgs>)

Adds a change listener on this replication object (similar to a C# event)

Declaration
public ListenerToken AddChangeListener(EventHandler<ReplicatorStatusChangedEventArgs> handler)
Parameters
Type Name Description
System.EventHandler<ReplicatorStatusChangedEventArgs> handler

The logic to run during the callback

Returns
Type Description
ListenerToken

A token to remove the handler later

| Improve this Doc View Source

AddChangeListener(TaskScheduler, EventHandler<ReplicatorStatusChangedEventArgs>)

Adds a change listener on this replication object (similar to a C# event, but with the ability to specify a System.Threading.Tasks.TaskScheduler to schedule the handler to run on)

Declaration
public ListenerToken AddChangeListener(TaskScheduler scheduler, EventHandler<ReplicatorStatusChangedEventArgs> handler)
Parameters
Type Name Description
System.Threading.Tasks.TaskScheduler scheduler

The System.Threading.Tasks.TaskScheduler to run the handler on (null for default)

System.EventHandler<ReplicatorStatusChangedEventArgs> handler

The logic to run during the callback

Returns
Type Description
ListenerToken

A token to remove the handler later

| Improve this Doc View Source

AddDocumentReplicationListener(EventHandler<DocumentReplicationEventArgs>)

Adds a documents ended listener on this replication object (similar to a C# event)

Declaration
public ListenerToken AddDocumentReplicationListener(EventHandler<DocumentReplicationEventArgs> handler)
Parameters
Type Name Description
System.EventHandler<DocumentReplicationEventArgs> handler

The logic to run during the callback

Returns
Type Description
ListenerToken

A token to remove the handler later

Remarks

Make sure add documents ended listener on this replication object before starting the replicator.

| Improve this Doc View Source

AddDocumentReplicationListener(TaskScheduler, EventHandler<DocumentReplicationEventArgs>)

Adds a document ended listener on this replication object (similar to a C# event, but with the ability to specify a System.Threading.Tasks.TaskScheduler to schedule the handler to run on)

Declaration
public ListenerToken AddDocumentReplicationListener(TaskScheduler scheduler, EventHandler<DocumentReplicationEventArgs> handler)
Parameters
Type Name Description
System.Threading.Tasks.TaskScheduler scheduler

The System.Threading.Tasks.TaskScheduler to run the handler on (null for default)

System.EventHandler<DocumentReplicationEventArgs> handler

The logic to run during the callback

Returns
Type Description
ListenerToken

A token to remove the handler later

Remarks

Make sure add documents ended listener on this replication object before starting the replicator.

| Improve this Doc View Source

Dispose()

Declaration
public void Dispose()
| Improve this Doc View Source

Finalize()

Finalizer

Declaration
protected void Finalize()
| Improve this Doc View Source

GetPendingDocumentIDs()

[DEPRECATED] Gets a list of document IDs that are going to be pushed, but have not been pushed yet API is a snapshot and results may change between the time the call was made and the time

Declaration
[Obsolete("GetPendingDocumentIDs() is deprecated, please use GetPendingDocumentIDs(Collection collection)")]
public IImmutableSet<string> GetPendingDocumentIDs()
Returns
Type Description
System.Collections.Immutable.IImmutableSet<System.String>

An immutable set of strings, each of which is a document ID

Exceptions
Type Condition
CouchbaseLiteException

Thrown if no push replication

CouchbaseException

Thrown if an error condition is returned from LiteCore

| Improve this Doc View Source

GetPendingDocumentIDs(Collection)

Gets a list of document IDs of docs in the given collection that are going to be pushed, but have not been pushed yet. If the given collection is not part of the replication, an Invalid Parameter Exception will be thrown. API is a snapshot and results may change between the time the call was made and the time

Declaration
public IImmutableSet<string> GetPendingDocumentIDs(Collection collection)
Parameters
Type Name Description
Collection collection

The collection contains the list of document IDs of docs

Returns
Type Description
System.Collections.Immutable.IImmutableSet<System.String>

An immutable set of strings, each of which is a document ID

Exceptions
Type Condition
CouchbaseLiteException

Thrown if no push replication

CouchbaseException

Thrown if an error condition is returned from LiteCore

| Improve this Doc View Source

IsDocumentPending(String)

[DEPRECATED] Checks whether or not a document with the given ID has any pending revisions to push

Declaration
[Obsolete("IsDocumentPending(string documentID) is deprecated, please use IsDocumentPending(string documentID, Collection collection)")]
public bool IsDocumentPending(string documentID)
Parameters
Type Name Description
System.String documentID

The document ID

Returns
Type Description
System.Boolean

A bool which represents whether or not the document with the corresponding ID has one or more pending revisions.
true means that one or more revisions have not been pushed to the remote yet, and false means that all revisions on the document have been pushed

Exceptions
Type Condition
CouchbaseLiteException

Thrown if no push replication

CouchbaseException

Thrown if an error condition is returned from LiteCore

| Improve this Doc View Source

IsDocumentPending(String, Collection)

Checks whether or not a document with the given ID in the given collection is pending to push or not. If the given collection is not part of the replication, an Invalid Parameter Exception will be thrown.

Declaration
public bool IsDocumentPending(string documentID, Collection collection)
Parameters
Type Name Description
System.String documentID

The document ID

Collection collection

The collection contains the doc with the given document ID

Returns
Type Description
System.Boolean

A bool which represents whether or not the document with the corresponding ID has one or more pending revisions.
true means that one or more revisions have not been pushed to the remote yet, and false means that all revisions on the document have been pushed

Exceptions
Type Condition
CouchbaseLiteException

Thrown if no push replication

CouchbaseException

Thrown if an error condition is returned from LiteCore

| Improve this Doc View Source

RemoveChangeListener(ListenerToken)

Removes a previously added change listener via its ListenerToken and/or Removes a previously added documents ended listener via its ListenerToken

Declaration
public void RemoveChangeListener(ListenerToken token)
Parameters
Type Name Description
ListenerToken token

The token received from AddChangeListener(TaskScheduler, EventHandler<ReplicatorStatusChangedEventArgs>) and/or The token received from AddDocumentReplicationListener(TaskScheduler, EventHandler<DocumentReplicationEventArgs>)

| Improve this Doc View Source

Start()

Starts the replication

Declaration
public void Start()
| Improve this Doc View Source

Start(Boolean)

Starts the replication with an option to reset the checkpoint.

Declaration
public void Start(bool reset)
Parameters
Type Name Description
System.Boolean reset

Resets the local checkpoint of the replicator, meaning that it will read all changes since the beginning of time from the remote database.

| Improve this Doc View Source

Stop()

Stops a running replicator. This method returns immediately; when the replicator actually stops, the replicator will change its status's activity level to Stopped and the replicator change notification will be notified accordingly.

Declaration
public void Stop()
| Improve this Doc View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
System.Object.ToString()

Implements

System.IDisposable
IChangeObservable<TEventType>
IDocumentReplicatedObservable
IChangeObservableRemovable
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX