Couchbase Lite C++
Couchbase Lite C++ API
Loading...
Searching...
No Matches
Replicator.hh
Go to the documentation of this file.
1//
2// Replicator.hh
3//
4// Copyright (c) 2019 Couchbase, Inc All rights reserved.
5//
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17//
18
19#pragma once
20#include "cbl++/Document.hh"
21#include "cbl/CBLReplicator.h"
22#include "cbl/CBLDefaults.h"
23#include <functional>
24#include <optional>
25#include <string>
26#include <string_view>
27#include <vector>
28#include <unordered_map>
29
30
32
33namespace cbl {
34
36 class Endpoint {
37 public:
45 static Endpoint urlEndpoint(std::string_view url) {
46 CBLError error {};
47 auto endpoint = CBLEndpoint_CreateWithURL(slice(url), &error);
48 internal::check(endpoint, error);
49 return Endpoint(endpoint);
50 }
51
52#ifdef COUCHBASE_ENTERPRISE
54 static Endpoint databaseEndpoint(Database db) {
55 return Endpoint(CBLEndpoint_CreateWithLocalDB(db.ref()));
56 }
57#endif
58
59 protected:
61
62 CBLEndpoint* _cbl_nullable ref() const {return _ref.get();}
63
64 private:
65 Endpoint() = default;
66
68 _ref = std::shared_ptr<CBLEndpoint>(ref, [](auto r) {
70 });
71 }
72
73 std::shared_ptr<CBLEndpoint> _ref;
74 };
75
77 class Authenticator {
78 public:
80 static Authenticator basicAuthenticator(std::string_view username, std::string_view password) {
81 return Authenticator(CBLAuth_CreatePassword(slice(username), slice(password)));
82 }
83
86 static Authenticator sessionAuthenticator(std::string_view sessionId, std::optional<std::string_view> cookieName =std::nullopt) {
87 slice cname;
88 if ( cookieName ) cname = *cookieName;
89 return Authenticator(CBLAuth_CreateSession(slice(sessionId), cname));
90 }
91
92 protected:
94
95 CBLAuthenticator* _cbl_nullable ref() const {return _ref.get();}
96
97 private:
98 Authenticator() = default;
99
101 _ref = std::shared_ptr<CBLAuthenticator>(ref, [](auto r) {
102 CBLAuth_Free(r);
103 });
104 }
105
106 std::shared_ptr<CBLAuthenticator> _ref;
107 };
108
110 using ReplicationFilter = std::function<bool(Document, CBLDocumentFlags flags)>;
111
113 using ConflictResolver = std::function<Document(std::string_view docID,
114 const Document localDoc,
115 const Document remoteDoc)>;
116
117#ifdef COUCHBASE_ENTERPRISE
120 fleece::alloc_slice ciphertext;
121 std::optional<std::string> algorithm;
122 std::optional<std::string> keyID;
124 };
125
128 fleece::alloc_slice plaintext;
130 };
131
134 using PropertyEncryptor = std::function<EncryptionResult(
135 fleece::slice scope,
136 fleece::slice collection,
137 fleece::slice documentID,
138 fleece::Dict properties,
139 fleece::slice keyPath,
140 fleece::slice input)>;
141
144 using PropertyDecryptor = std::function<DecryptionResult(
145 fleece::slice scope,
146 fleece::slice collection,
147 fleece::slice documentID,
148 fleece::Dict properties,
149 fleece::slice keyPath,
150 fleece::slice input,
151 std::optional<std::string_view> algorithm,
152 std::optional<std::string_view> keyID)>;
153#endif
154
158 public:
163
164 //-- Accessors:
166 Collection collection() const {return _collection;}
167
168 //-- Filtering:
170 fleece::MutableArray channels = fleece::MutableArray::newArray();
171
173 fleece::MutableArray documentIDs = fleece::MutableArray::newArray();
174
177
180
181 //-- Conflict Resolver:
184
185 private:
186 Collection _collection;
187 };
188
192
195 public:
199 ReplicatorConfiguration(std::vector<CollectionConfiguration>collections, Endpoint endpoint)
200 :_collections(collections)
201 ,_endpoint(endpoint)
202 { }
203
204 //-- Accessors:
205
207 std::vector<CollectionConfiguration> collections() const {return _collections;}
208
210 Endpoint endpoint() const {return _endpoint;}
211
212 //-- Types:
216 bool continuous = false;
217
218 //-- Auto Purge:
222 bool enableAutoPurge = true;
223
224 //-- Retry Logic:
228 unsigned maxAttempts = 0;
231 unsigned maxAttemptWaitTime = 0;
232
233 //-- WebSocket:
236 unsigned heartbeat = 0;
237
238 #ifdef __CBL_REPLICATOR_NETWORK_INTERFACE__
242 std::string networkInterface;
243 #endif
244
245 //-- HTTP settings:
251 fleece::MutableDict headers = fleece::MutableDict::newDict();
252
253 //-- Advance HTTP settings:
263
264 //-- TLS settings:
270#ifdef COUCHBASE_ENTERPRISE
274#endif
275
276#ifdef COUCHBASE_ENTERPRISE
277 //-- Property Encryption (Enterprise Edition only):
282#endif
283
284 protected:
285 friend class Replicator;
286
288 operator CBLReplicatorConfiguration() const {
290 conf.endpoint = _endpoint.ref();
291 assert(conf.endpoint);
293 conf.continuous = continuous;
297 conf.heartbeat = heartbeat;
298 conf.authenticator = authenticator.ref();
300 conf.proxy = proxy;
301 if (!headers.empty())
302 conf.headers = headers;
303 #ifdef __CBL_REPLICATOR_NETWORK_INTERFACE__
304 if (!networkInterface.empty())
305 conf.networkInterface = slice(networkInterface);
306 #endif
307 if (!pinnedServerCertificate.empty())
309 if (!trustedRootCertificates.empty())
311#ifdef COUCHBASE_ENTERPRISE
313#endif
314 return conf;
315 }
316
317 private:
318 Endpoint _endpoint;
319 std::vector<CollectionConfiguration> _collections;
320 };
321
323 class Replicator : private RefCounted {
324 public:
327 {
328 // Get the current configured collections and populate one for the
329 // default collection if the config is configured with the database:
330 auto collections = config.collections();
331
332 // Create a shared context. Its pointer is passed as the C-level context so
333 // that all captureless C callbacks (filters, conflict resolver, encryptor,
334 // decryptor) can reach both the collection map and the crypto functions.
335 _context = std::make_shared<ReplicatorContext>();
336
337 // Get base C config:
338 CBLReplicatorConfiguration c_config = config;
339
340 // Construct C replication collections to set to the c_config:
341 std::vector<CBLCollectionConfiguration> colConfigs;
342 for (int i = 0; i < collections.size(); i++) {
343 CollectionConfiguration& col = collections[i];
344
345 CBLCollectionConfiguration colConfig {};
346 colConfig.collection = col.collection().ref();
347
348 if (!col.channels.empty()) {
349 colConfig.channels = col.channels;
350 }
351
352 if (!col.documentIDs.empty()) {
353 colConfig.documentIDs = col.documentIDs;
354 }
355
356 if (col.pushFilter) {
357 colConfig.pushFilter = [](void* context,
358 CBLDocument* cDoc,
359 CBLDocumentFlags flags) -> bool {
360 auto doc = Document(cDoc);
361 auto ctx = (ReplicatorContext*)context;
362 return ctx->collectionMap.find(doc.collection())->second.pushFilter(doc, flags);
363 };
364 }
365
366 if (col.pullFilter) {
367 colConfig.pullFilter = [](void* context,
368 CBLDocument* cDoc,
369 CBLDocumentFlags flags) -> bool {
370 auto doc = Document(cDoc);
371 auto ctx = (ReplicatorContext*)context;
372 return ctx->collectionMap.find(doc.collection())->second.pullFilter(doc, flags);
373 };
374 }
375
376 if (col.conflictResolver) {
377 colConfig.conflictResolver = [](void* context,
378 FLString docID,
379 const CBLDocument* cLocalDoc,
380 const CBLDocument* cRemoteDoc) -> const CBLDocument*
381 {
382 auto localDoc = Document(cLocalDoc);
383 auto remoteDoc = Document(cRemoteDoc);
384 auto collection = localDoc ? localDoc.collection() : remoteDoc.collection();
385
386 auto ctx = (ReplicatorContext*)context;
387 auto resolved = ctx->collectionMap.find(collection)->second.
388 conflictResolver((std::string_view)slice(docID), localDoc, remoteDoc);
389
390 auto ref = resolved.ref();
391 if (ref && ref != cLocalDoc && ref != cRemoteDoc) {
393 }
394 return ref;
395 };
396 }
397 colConfigs.push_back(colConfig);
398 _context->collectionMap.insert({col.collection(), col});
399 }
400
401 c_config.collections = colConfigs.data();
402 c_config.collectionCount = colConfigs.size();
403 c_config.context = _context.get();
404
405#ifdef COUCHBASE_ENTERPRISE
406 if (config.documentPropertyEncryptor) {
407 _context->encryptor = config.documentPropertyEncryptor;
408 c_config.documentPropertyEncryptor = [](void* context,
409 FLString scope,
410 FLString collection,
411 FLString documentID,
412 FLDict properties,
413 FLString keyPath,
414 FLSlice input,
415 FLStringResult* algorithm,
416 FLStringResult* keyID,
417 CBLError* error) -> FLSliceResult {
418 auto ctx = (ReplicatorContext*)context;
419 auto r = ctx->encryptor(scope, collection, documentID, properties, keyPath, input);
420 if (error) *error = r.error;
421 if (algorithm) *algorithm = r.algorithm ? FLStringResult(slice(*r.algorithm)) : FLStringResult{};
422 if (keyID) *keyID = r.keyID ? FLStringResult(slice(*r.keyID)) : FLStringResult{};
423 return FLSliceResult(r.ciphertext);
424 };
425 }
426
427 if (config.documentPropertyDecryptor) {
428 _context->decryptor = config.documentPropertyDecryptor;
429 c_config.documentPropertyDecryptor = [](void* context,
430 FLString scope,
431 FLString collection,
432 FLString documentID,
433 FLDict properties,
434 FLString keyPath,
435 FLSlice input,
436 FLString algorithm,
437 FLString keyID,
438 CBLError* error) -> FLSliceResult {
439 auto ctx = (ReplicatorContext*)context;
440 auto toOpt = [](FLString s) -> std::optional<std::string_view> {
441 return s.buf ? std::optional<std::string_view>{{(const char*)s.buf, s.size}} : std::nullopt;
442 };
443 auto r = ctx->decryptor(scope, collection, documentID, properties, keyPath, input,
444 toOpt(algorithm), toOpt(keyID));
445 if (error) *error = r.error;
446 return FLSliceResult(r.plaintext);
447 };
448 }
449#endif
450
451 CBLError error {};
452 _ref = (CBLRefCounted*) CBLReplicator_Create(&c_config, &error);
453 internal::check(_ref, error);
454 }
455
463 void start(bool resetCheckpoint =false) {CBLReplicator_Start(ref(), resetCheckpoint);}
464
469
476
483
486
490 std::string correlationID() const {return internal::asString(CBLReplicator_CorrelationID(ref()));}
491
500 fleece::Dict pendingDocumentIDs(Collection& collection) const {
501 CBLError error;
502 fleece::Dict result = CBLReplicator_PendingDocumentIDs(ref(), collection.ref(), &error);
503 internal::check(result != nullptr, error);
504 return result;
505 }
506
515 bool isDocumentPending(std::string_view docID, Collection& collection) const {
516 CBLError error;
517 bool pending = CBLReplicator_IsDocumentPending(ref(), slice(docID), collection.ref(), &error);
518 internal::check(pending || error.code == 0, error);
519 return pending;
520 }
521
527
532 auto l = ChangeListener(callback);
533 l.setToken( CBLReplicator_AddChangeListener(ref(), &_callChangeListener, l.context()) );
534 return l;
535 }
536
542 const std::vector<CBLReplicatedDocument>>;
543
548 auto l = DocumentReplicationListener(callback);
549 l.setToken( CBLReplicator_AddDocumentReplicationListener(ref(), &_callDocListener, l.context()) );
550 return l;
551 }
552
553 private:
554 static void _callChangeListener(void* _cbl_nullable context,
555 CBLReplicator *repl,
557 {
558 ChangeListener::call(context, Replicator(repl), *status);
559 }
560
561 static void _callDocListener(void* _cbl_nullable context,
562 CBLReplicator *repl,
563 bool isPush,
564 unsigned numDocuments,
565 const CBLReplicatedDocument* documents)
566 {
567 std::vector<CBLReplicatedDocument> docs(&documents[0], &documents[numDocuments]);
568 DocumentReplicationListener::call(context, Replicator(repl), isPush, docs);
569 }
570
571 using CollectionToReplCollectionMap = std::unordered_map<Collection, CollectionConfiguration>;
572
573 struct ReplicatorContext {
574 CollectionToReplCollectionMap collectionMap;
575#ifdef COUCHBASE_ENTERPRISE
576 PropertyEncryptor encryptor;
577 PropertyDecryptor decryptor;
578#endif
579 };
580 std::shared_ptr<ReplicatorContext> _context;
581
583
584 public:
588 Replicator(const Replicator &other) noexcept
589 :RefCounted(other)
590 ,_context(other._context)
591 { }
592
595 Replicator(Replicator &&other) noexcept
596 :RefCounted((RefCounted&&)other)
597 ,_context(std::move(other._context))
598 { }
599
603 Replicator& operator=(const Replicator &other) noexcept {
604 RefCounted::operator=(other);
605 _context = other._context;
606 return *this;
607 }
608
612 Replicator& operator=(Replicator &&other) noexcept {
613 RefCounted::operator=((RefCounted&&)other);
614 _context = std::move(other._context);
615 return *this;
616 }
617
621 void clear() {
622 RefCounted::clear();
623 _context.reset();
624 }
625 };
626}
627
#define CBL_REFCOUNTED_WITHOUT_COPY_MOVE_BOILERPLATE(CLASS, SUPER, C_TYPE)
Definition Base.hh:140
#define _cbl_nullable
#define CBL_ASSUME_NONNULL_END
#define CBL_ASSUME_NONNULL_BEGIN
Authentication credentials for a remote server.
Definition Replicator.hh:77
friend class ReplicatorConfiguration
Definition Replicator.hh:93
CBLAuthenticator *_Nullable ref() const
Definition Replicator.hh:95
static Authenticator basicAuthenticator(std::string_view username, std::string_view password)
Creates a basic authenticator authenticator using username/password credentials.
Definition Replicator.hh:80
static Authenticator sessionAuthenticator(std::string_view sessionId, std::optional< std::string_view > cookieName=std::nullopt)
Creates a sesssion authenticator using a Couchbase Sync Gateway login session identifier,...
Definition Replicator.hh:86
A collection to replicate, along with its collection-specific replication settings such as filters an...
Definition Replicator.hh:157
fleece::MutableArray documentIDs
Optional set of document IDs to replicate.
Definition Replicator.hh:173
Collection collection() const
The collection.
Definition Replicator.hh:166
ReplicationFilter pushFilter
Optional callback to filter which docs are pushed.
Definition Replicator.hh:176
fleece::MutableArray channels
Optional set of channels to pull from.
Definition Replicator.hh:170
ReplicationFilter pullFilter
Optional callback to filter which docs are pulled.
Definition Replicator.hh:179
CollectionConfiguration(Collection collection)
Creates CollectionConfiguration with the collection.
Definition Replicator.hh:160
ConflictResolver conflictResolver
Optional conflict-resolver callback.
Definition Replicator.hh:183
A Collection is a container for documents within a database.
Definition Collection.hh:131
CBLCollection *_Nullable ref() const
Returns a pointer to the underlying C object (CBLCollection), or NULL if this is a null reference.
Definition Collection.hh:373
A Couchbase Lite database, which is a container for collections of documents.
Definition Database.hh:147
CBLDatabase *_Nullable ref() const
Returns a pointer to the underlying C object (CBLDatabase), or NULL if this is a null reference.
Definition Database.hh:411
An immutable, in-memory copy of a document read from a collection.
Definition Document.hh:33
The replication endpoint representing the location of a database to replicate with.
Definition Replicator.hh:36
static Endpoint databaseEndpoint(Database db)
Creates a database endpoint with another local database.
Definition Replicator.hh:54
friend class ReplicatorConfiguration
Definition Replicator.hh:60
static Endpoint urlEndpoint(std::string_view url)
Creates a URL endpoint with a given URL.
Definition Replicator.hh:45
CBLEndpoint *_Nullable ref() const
Definition Replicator.hh:62
A token representing a registered listener; instances are returned from the various methods that regi...
Definition Base.hh:177
static void call(void *_Nullable context, Args... args)
Definition Base.hh:228
std::function< void(Args...)> Callback
Definition Base.hh:180
The configuration of a replicator.
Definition Replicator.hh:194
CBLReplicatorType replicatorType
Replicator type : Push, pull or both.
Definition Replicator.hh:214
std::string pinnedServerCertificate
An X.509 cert (PEM or DER) to "pin" for TLS connections.
Definition Replicator.hh:267
unsigned maxAttempts
Max retry attempts where the initial connect to replicate counts toward the given value.
Definition Replicator.hh:228
Authenticator authenticator
Authentication credentials, if needed.
Definition Replicator.hh:247
unsigned heartbeat
The heartbeat interval in seconds.
Definition Replicator.hh:236
ReplicatorConfiguration(std::vector< CollectionConfiguration >collections, Endpoint endpoint)
Creates a config with a list of collections and per-collection configurations to replicate and an end...
Definition Replicator.hh:199
unsigned maxAttemptWaitTime
Max wait time between retry attempts in seconds.
Definition Replicator.hh:231
std::string trustedRootCertificates
Set of anchor certs (PEM format).
Definition Replicator.hh:269
CBLProxySettings *_Nullable proxy
HTTP client proxy settings.
Definition Replicator.hh:249
Endpoint endpoint() const
Returns the configured endpoint.
Definition Replicator.hh:210
friend class Replicator
Definition Replicator.hh:285
bool acceptParentDomainCookies
The option to remove the restriction that does not allow the replicator to save the parent-domain coo...
Definition Replicator.hh:262
bool continuous
Continuous replication or single-shot replication.
Definition Replicator.hh:216
std::vector< CollectionConfiguration > collections() const
Returns the configured collections.
Definition Replicator.hh:207
PropertyDecryptor documentPropertyDecryptor
Optional callback to decrypt encrypted properties during pull replication.
Definition Replicator.hh:281
bool acceptOnlySelfSignedServerCertificate
Accept only self-signed server certificates; any other certificates are rejected.
Definition Replicator.hh:273
fleece::MutableDict headers
Extra HTTP headers to add to the WebSocket request.
Definition Replicator.hh:251
PropertyEncryptor documentPropertyEncryptor
Optional callback to encrypt encryptable properties during push replication.
Definition Replicator.hh:279
bool enableAutoPurge
Enabled auto-purge or not.
Definition Replicator.hh:222
void stop()
Stops a running replicator, asynchronously.
Definition Replicator.hh:468
Replicator(Replicator &&other) noexcept
Move constructor.
Definition Replicator.hh:595
cbl::ListenerToken< Replicator, bool, const std::vector< CBLReplicatedDocument > > DocumentReplicationListener
A document replication listener that notifies you when documents are replicated.
Definition Replicator.hh:541
CBLReplicatorStatus status() const
Returns the replicator's current status.
Definition Replicator.hh:485
Replicator() noexcept
Constructs a null reference (one that points to no object).
Definition Replicator.hh:582
Replicator(const Replicator &other) noexcept
Copy constructor.
Definition Replicator.hh:588
DocumentReplicationListener addDocumentReplicationListener(DocumentReplicationListener::Callback callback)
Registers a listener that will be called when documents are replicated.
Definition Replicator.hh:547
bool isDocumentPending(std::string_view docID, Collection &collection) const
Indicates whether the document with the given ID in the given collection has local changes that have ...
Definition Replicator.hh:515
Replicator & operator=(Replicator &&other) noexcept
Move assignment.
Definition Replicator.hh:612
void setHostReachable(bool r)
Informs the replicator whether it's considered possible to reach the remote host with the current net...
Definition Replicator.hh:475
Replicator & operator=(const Replicator &other) noexcept
Copy assignment.
Definition Replicator.hh:603
void setSuspended(bool s)
Puts the replicator in or out of "suspended" state.
Definition Replicator.hh:482
cbl::ListenerToken< Replicator, const CBLReplicatorStatus & > ChangeListener
A change listener that notifies you when the replicator's status changes.
Definition Replicator.hh:526
void clear()
Releases the underlying C CBLReplicator and drops the C++ collection-configuration map.
Definition Replicator.hh:621
void start(bool resetCheckpoint=false)
Starts a replicator, asynchronously.
Definition Replicator.hh:463
Replicator(const ReplicatorConfiguration &config)
Creates a new replicator using the specified config.
Definition Replicator.hh:326
ChangeListener addChangeListener(ChangeListener::Callback callback)
Registers a listener that will be called when the replicator's status changes.
Definition Replicator.hh:531
fleece::Dict pendingDocumentIDs(Collection &collection) const
Indicates which documents in the given collection have local changes that have not yet been pushed to...
Definition Replicator.hh:500
std::string correlationID() const
Returns the ID used to correlate the replication session with the remote endpoint.
Definition Replicator.hh:490
CBLReplicator *_Nullable ref() const
Returns a pointer to the underlying C object (CBLReplicator), or NULL if this is a null reference.
Definition Replicator.hh:582
FLSliceResult FLStringResult
FLSlice FLString
CBL_PUBLIC const bool kCBLDefaultReplicatorAcceptParentCookies
CBLINLINE const CBLDocument * CBLDocument_Retain(const CBLDocument *_cbl_nullable t)
struct CBLDocument CBLDocument
struct CBLRefCounted CBLRefCounted
struct CBLAuthenticator CBLAuthenticator
_cbl_warn_unused CBLAuthenticator * CBLAuth_CreateSession(FLString sessionID, FLString cookieName)
struct CBLEndpoint CBLEndpoint
void CBLReplicator_Start(CBLReplicator *replicator, bool resetCheckpoint)
_cbl_warn_unused CBLAuthenticator * CBLAuth_CreatePassword(FLString username, FLString password)
FLDict _cbl_nullable CBLReplicator_PendingDocumentIDs(CBLReplicator *, const CBLCollection *collection, CBLError *_cbl_nullable outError)
bool CBLReplicator_IsDocumentPending(CBLReplicator *repl, FLString docID, const CBLCollection *collection, CBLError *_cbl_nullable outError)
void CBLReplicator_Stop(CBLReplicator *)
struct CBLReplicator CBLReplicator
_cbl_warn_unused CBLReplicator *_cbl_nullable CBLReplicator_Create(const CBLReplicatorConfiguration *, CBLError *_cbl_nullable outError)
_cbl_warn_unused FLStringResult CBLReplicator_CorrelationID(CBLReplicator *)
CBLReplicatorStatus CBLReplicator_Status(CBLReplicator *)
void CBLEndpoint_Free(CBLEndpoint *_cbl_nullable)
_cbl_warn_unused CBLListenerToken * CBLReplicator_AddChangeListener(CBLReplicator *, CBLReplicatorChangeListener, void *_cbl_nullable context)
void CBLAuth_Free(CBLAuthenticator *_cbl_nullable)
CBLDocumentFlags
CBLReplicatorType
void CBLReplicator_SetSuspended(CBLReplicator *repl, bool suspended)
void CBLReplicator_SetHostReachable(CBLReplicator *, bool reachable)
_cbl_warn_unused CBLEndpoint * CBLEndpoint_CreateWithLocalDB(CBLDatabase *)
_cbl_warn_unused CBLListenerToken * CBLReplicator_AddDocumentReplicationListener(CBLReplicator *, CBLDocumentReplicationListener, void *_cbl_nullable context)
_cbl_warn_unused CBLEndpoint *_cbl_nullable CBLEndpoint_CreateWithURL(FLString url, CBLError *_cbl_nullable outError)
kCBLReplicatorTypePushAndPull
const struct _FLDict * FLDict
Definition Base.hh:46
fleece::slice slice
Convenience alias for fleece::slice, a non-owning view of a byte range.
Definition Base.hh:49
std::function< Document(std::string_view docID, const Document localDoc, const Document remoteDoc)> ConflictResolver
Replication Conflict Resolver Function Callback.
Definition Replicator.hh:113
std::function< EncryptionResult( fleece::slice scope, fleece::slice collection, fleece::slice documentID, fleece::Dict properties, fleece::slice keyPath, fleece::slice input)> PropertyEncryptor
Property Encryptor Function Callback.
Definition Replicator.hh:134
std::function< bool(Document, CBLDocumentFlags flags)> ReplicationFilter
Replication Filter Function Callback.
Definition Replicator.hh:110
CollectionConfiguration ReplicationCollection
Deprecated alias for backward compatibility.
Definition Replicator.hh:191
std::function< DecryptionResult( fleece::slice scope, fleece::slice collection, fleece::slice documentID, fleece::Dict properties, fleece::slice keyPath, fleece::slice input, std::optional< std::string_view > algorithm, std::optional< std::string_view > keyID)> PropertyDecryptor
Property Decryptor Function Callback.
Definition Replicator.hh:144
CBLConflictResolver _cbl_nullable conflictResolver
CBLCollection * collection
CBLReplicationFilter _cbl_nullable pullFilter
FLArray _cbl_nullable documentIDs
FLArray _cbl_nullable channels
CBLReplicationFilter _cbl_nullable pushFilter
void *_cbl_nullable context
const CBLProxySettings *_cbl_nullable proxy
CBLCollectionConfiguration * collections
CBLReplicatorType replicatorType
FLDict _cbl_nullable headers
CBLAuthenticator *_cbl_nullable authenticator
CBLDocumentPropertyEncryptor _cbl_nullable documentPropertyEncryptor
CBLDocumentPropertyDecryptor _cbl_nullable documentPropertyDecryptor
Result returned by a PropertyDecryptor callback.
Definition Replicator.hh:127
fleece::alloc_slice plaintext
Decrypted data. Empty = leave property in encrypted form.
Definition Replicator.hh:128
CBLError error
Optional error. Non-zero aborts replication for this doc.
Definition Replicator.hh:129
Result returned by a PropertyEncryptor callback.
Definition Replicator.hh:119
std::optional< std::string > keyID
Optional key identifier.
Definition Replicator.hh:122
fleece::alloc_slice ciphertext
Encrypted data. Empty = skip (results in a crypto error).
Definition Replicator.hh:120
CBLError error
Optional error. Non-zero aborts replication for this doc.
Definition Replicator.hh:123
std::optional< std::string > algorithm
Optional algorithm name. Default: "CB_MOBILE_CUSTOM".
Definition Replicator.hh:121