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
Implements
Inherited Members
Namespace: Couchbase.Lite.Sync
Assembly: Couchbase.Lite.dll
Syntax
public sealed class Replicator : IDisposable, IStoppable
Constructors
| Improve this Doc View SourceReplicator(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 SourceConfig
Gets the configuration that was used to create this Replicator
Declaration
public ReplicatorConfiguration Config { get; }
Property Value
Type | Description |
---|---|
ReplicatorConfiguration |
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 |
Status
Gets the current status of the Replicator
Declaration
public ReplicatorStatus Status { get; set; }
Property Value
Type | Description |
---|---|
ReplicatorStatus |
Methods
| Improve this Doc View SourceAddChangeListener(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 |
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 |
System.EventHandler<ReplicatorStatusChangedEventArgs> | handler | The logic to run during the callback |
Returns
Type | Description |
---|---|
ListenerToken | A token to remove the handler later |
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.
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 |
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.
Dispose()
Declaration
public void Dispose()
Finalize()
Finalizer
Declaration
protected void Finalize()
GetPendingDocumentIDs()
Gets a list of document IDs that are going to be pushed, but have not been pushed yet
Declaration
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 |
IsDocumentPending(String)
Checks whether or not a document with the given ID has any pending revisions to push
Declaration
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. |
Exceptions
Type | Condition |
---|---|
CouchbaseLiteException | Thrown if no push replication |
CouchbaseException | Thrown if an error condition is returned from LiteCore |
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>) |
ResetCheckpoint()
[DEPRECATED] Resets the local checkpoint of the replicator, meaning that it will read all changes since the beginning of time from the remote database. This can only be called when the replicator is in a stopped state.
Declaration
[Obsolete("This method deprecated, please use Start(bool reset) to reset checkpoint when starting the replicator.")]
public void ResetCheckpoint()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if this method is called while the replicator is not in a stopped state |
Start()
Starts the replication
Declaration
public void Start()
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. |
Stop()
Stops the replication
Declaration
public void Stop()
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |