Ditto 5.0.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ditto::SyncSubscription Class Reference

A sync subscription configures Ditto to receive updates from remote peers about documents matching the subscription's query. More...

Public Member Functions

 SyncSubscription (const SyncSubscription &)=delete
 
SyncSubscriptionoperator= (const SyncSubscription &)=delete
 
 SyncSubscription (SyncSubscription &&) noexcept=default
 
SyncSubscriptionoperator= (SyncSubscription &&) noexcept=default
 
bool operator< (const SyncSubscription &other) const
 
void cancel ()
 Cancels the sync subscription so that new changes matching the query are no longer received from other peers. No-op if it's already cancelled via or the owning Ditto object goes out of scope.
 
bool is_cancelled ()
 
std::string get_query () const
 Returns the query string that was used to create the subscription.
 
nlohmann::json get_query_arguments () const
 Returns the query arguments that were used to create the subscription.
 
std::vector< uint8_t > get_query_arguments_cbor_data () const
 Returns the query arguments that were used to create the subscription, as a CBOR-encoded byte vector.
 
std::string get_query_arguments_json_string () const
 Returns the query arguments that were used to create the subscription, as a JSON-encoded string.
 

Detailed Description

A sync subscription configures Ditto to receive updates from remote peers about documents matching the subscription's query.

Member Function Documentation

◆ get_query_arguments()

nlohmann::json ditto::SyncSubscription::get_query_arguments ( ) const

Returns the query arguments that were used to create the subscription.

Note
The returned value is not guaranteed to be strictly equal to the value provided when making the call to Store::register_observer, as the arguments will have gone through a serialization roundtrip. This might affect equality checks, particularly for non-primitive values. If you want to have more control over how to deserialize the query arguments then use get_query_arguments_cbor_data or get_query_arguments_json_string.

◆ is_cancelled()

bool ditto::SyncSubscription::is_cancelled ( )

Convenience property, returns true if the sync subscription has been cancelled, otherwise returns false. Also, a sync subscription is considered cancelled if the owning Ditto object goes out of scope.