2017-10-03 08:55:22 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright 2017 Google
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
|
2020-04-15 12:01:09 -04:00
|
|
|
#include <cstddef>
|
2018-03-27 14:33:39 -04:00
|
|
|
#include <map>
|
2019-09-12 14:28:10 -07:00
|
|
|
#include <memory>
|
2018-02-15 17:23:08 -05:00
|
|
|
#include <unordered_map>
|
2020-01-08 12:04:28 -05:00
|
|
|
#include <utility>
|
2019-02-06 20:23:29 -05:00
|
|
|
#include <vector>
|
2018-02-15 17:23:08 -05:00
|
|
|
|
2021-03-16 17:07:47 -04:00
|
|
|
#include "Firestore/core/src/api/load_bundle_task.h"
|
|
|
|
|
#include "Firestore/core/src/bundle/bundle_reader.h"
|
|
|
|
|
#include "Firestore/core/src/core/database_info.h"
|
2020-04-20 14:57:34 -07:00
|
|
|
#include "Firestore/core/src/core/query.h"
|
|
|
|
|
#include "Firestore/core/src/core/view_snapshot.h"
|
2021-10-07 14:16:58 -06:00
|
|
|
#include "Firestore/core/src/credentials/user.h"
|
2020-04-20 14:57:34 -07:00
|
|
|
#include "Firestore/core/src/model/model_fwd.h"
|
|
|
|
|
#include "Firestore/core/src/nanopb/byte_string.h"
|
|
|
|
|
#include "Firestore/core/src/nanopb/nanopb_util.h"
|
|
|
|
|
#include "Firestore/core/src/remote/watch_change.h"
|
|
|
|
|
#include "Firestore/core/src/util/async_queue.h"
|
|
|
|
|
#include "Firestore/core/src/util/empty.h"
|
2018-02-15 17:23:08 -05:00
|
|
|
|
2019-09-12 14:28:10 -07:00
|
|
|
namespace firebase {
|
|
|
|
|
namespace firestore {
|
|
|
|
|
namespace local {
|
|
|
|
|
|
|
|
|
|
class Persistence;
|
2020-02-15 14:34:38 -08:00
|
|
|
class TargetData;
|
2019-09-12 14:28:10 -07:00
|
|
|
|
|
|
|
|
} // namespace local
|
|
|
|
|
} // namespace firestore
|
|
|
|
|
} // namespace firebase
|
2017-10-03 08:55:22 -07:00
|
|
|
|
2021-03-16 17:07:47 -04:00
|
|
|
namespace api = firebase::firestore::api;
|
|
|
|
|
namespace bundle = firebase::firestore::bundle;
|
2019-08-02 11:35:33 -07:00
|
|
|
namespace core = firebase::firestore::core;
|
2021-10-07 14:16:58 -06:00
|
|
|
namespace credentials = firebase::firestore::credentials;
|
2019-08-20 14:56:32 -07:00
|
|
|
namespace local = firebase::firestore::local;
|
2019-08-14 23:18:47 -07:00
|
|
|
namespace model = firebase::firestore::model;
|
2020-02-15 14:34:38 -08:00
|
|
|
namespace remote = firebase::firestore::remote;
|
2020-01-08 12:04:28 -05:00
|
|
|
|
|
|
|
|
// A map holds expected information about currently active targets. The keys are
|
2021-03-16 17:07:47 -04:00
|
|
|
// target ID, and the values are a vector of `TargetData`s mapped to the target.
|
|
|
|
|
using ActiveTargetMap = std::unordered_map<model::TargetId, std::vector<local::TargetData>>;
|
2019-08-02 11:35:33 -07:00
|
|
|
|
2017-10-03 08:55:22 -07:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Interface used for object that contain exactly one of either a view snapshot or an error for the
|
|
|
|
|
* given query.
|
|
|
|
|
*/
|
|
|
|
|
@interface FSTQueryEvent : NSObject
|
2019-08-02 11:35:33 -07:00
|
|
|
@property(nonatomic, assign) core::Query query;
|
2017-10-03 08:55:22 -07:00
|
|
|
@property(nonatomic, strong, nullable) NSError *error;
|
2019-03-01 14:16:41 -05:00
|
|
|
|
2020-02-15 14:34:38 -08:00
|
|
|
- (const absl::optional<core::ViewSnapshot> &)viewSnapshot;
|
|
|
|
|
- (void)setViewSnapshot:(absl::optional<core::ViewSnapshot>)snapshot;
|
2019-03-01 14:16:41 -05:00
|
|
|
|
2017-10-03 08:55:22 -07:00
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
/** Holds an outstanding write and its result. */
|
|
|
|
|
@interface FSTOutstandingWrite : NSObject
|
2019-08-14 23:18:47 -07:00
|
|
|
|
2017-10-03 08:55:22 -07:00
|
|
|
/** The write that is outstanding. */
|
2019-08-14 23:18:47 -07:00
|
|
|
- (const model::Mutation &)write;
|
|
|
|
|
- (void)setWrite:(model::Mutation)write;
|
|
|
|
|
|
2017-10-03 08:55:22 -07:00
|
|
|
/** Whether this write is done (regardless of whether it was successful or not). */
|
|
|
|
|
@property(nonatomic, assign, readwrite) BOOL done;
|
2019-08-14 23:18:47 -07:00
|
|
|
|
2017-10-03 08:55:22 -07:00
|
|
|
/** The error - if any - of this write. */
|
|
|
|
|
@property(nonatomic, strong, nullable, readwrite) NSError *error;
|
2019-08-14 23:18:47 -07:00
|
|
|
|
2017-10-03 08:55:22 -07:00
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
/** Mapping of user => array of FSTMutations for that user. */
|
2021-10-07 14:16:58 -06:00
|
|
|
typedef std::
|
|
|
|
|
unordered_map<credentials::User, NSMutableArray<FSTOutstandingWrite *> *, credentials::HashUser>
|
|
|
|
|
FSTOutstandingWriteQueues;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A test driver for FSTSyncEngine that allows simulated event delivery and capture. As much as
|
|
|
|
|
* possible, all sources of nondeterminism are removed so that test execution is consistent and
|
|
|
|
|
* reliable.
|
|
|
|
|
*
|
|
|
|
|
* FSTSyncEngineTestDriver:
|
|
|
|
|
*
|
2019-01-18 13:58:23 -05:00
|
|
|
* + constructs an FSTSyncEngine using a mocked Datastore for the backend;
|
|
|
|
|
* + allows the caller to trigger events (user API calls and incoming Datastore messages);
|
2017-10-03 08:55:22 -07:00
|
|
|
* + performs sequencing validation internally (e.g. that when a user mutation is initiated, the
|
|
|
|
|
* FSTSyncEngine correctly sends it to the remote store); and
|
|
|
|
|
* + exposes the set of FSTQueryEvents generated for the caller to verify.
|
|
|
|
|
*
|
|
|
|
|
* Events come in three major flavors:
|
|
|
|
|
*
|
|
|
|
|
* + user events: simulate user API calls
|
|
|
|
|
* + watch events: simulate RPC interactions with the Watch backend
|
|
|
|
|
* + write events: simulate RPC interactions with the Streaming Write backend
|
|
|
|
|
*
|
|
|
|
|
* Each method on the driver injects a different event into the system.
|
|
|
|
|
*/
|
2019-02-01 15:44:18 -05:00
|
|
|
@interface FSTSyncEngineTestDriver : NSObject
|
2017-10-03 08:55:22 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initializes the underlying FSTSyncEngine with the given local persistence implementation and
|
2019-09-12 14:28:10 -07:00
|
|
|
* a set of existing outstandingWrites (useful when your Persistence object has persisted
|
|
|
|
|
* mutation queues).
|
2017-10-03 08:55:22 -07:00
|
|
|
*/
|
2019-09-12 14:28:10 -07:00
|
|
|
- (instancetype)initWithPersistence:(std::unique_ptr<local::Persistence>)persistence
|
2023-04-18 13:00:05 -04:00
|
|
|
eagerGC:(BOOL)eagerGC
|
2021-10-07 14:16:58 -06:00
|
|
|
initialUser:(const credentials::User &)initialUser
|
2018-02-15 17:23:08 -05:00
|
|
|
outstandingWrites:(const FSTOutstandingWriteQueues &)outstandingWrites
|
2020-04-15 12:01:09 -04:00
|
|
|
maxConcurrentLimboResolutions:(size_t)maxConcurrentLimboResolutions NS_DESIGNATED_INITIALIZER;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
|
|
|
|
|
|
|
|
/** Starts the FSTSyncEngine and its underlying components. */
|
|
|
|
|
- (void)start;
|
|
|
|
|
|
|
|
|
|
/** Validates that the API has been used correctly after a test is complete. */
|
|
|
|
|
- (void)validateUsage;
|
|
|
|
|
|
|
|
|
|
/** Shuts the FSTSyncEngine down. */
|
|
|
|
|
- (void)shutdown;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a listener to the FSTSyncEngine as if the user had initiated a new listen for the given
|
|
|
|
|
* query.
|
|
|
|
|
*
|
|
|
|
|
* Resulting events are captured and made available via the capturedEventsSinceLastCall method.
|
|
|
|
|
*
|
|
|
|
|
* @param query A valid query to execute against the backend.
|
2024-03-11 14:53:11 -04:00
|
|
|
* @param options A listen option to configure snapshot listener.
|
2017-10-03 08:55:22 -07:00
|
|
|
* @return The target ID assigned by the system to track the query.
|
|
|
|
|
*/
|
2024-03-11 14:53:11 -04:00
|
|
|
- (model::TargetId)addUserListenerWithQuery:(core::Query)query options:(core::ListenOptions)options;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes a listener from the FSTSyncEngine as if the user had removed a listener corresponding
|
|
|
|
|
* to the given query.
|
|
|
|
|
*
|
|
|
|
|
* Resulting events are captured and made available via the capturedEventsSinceLastCall method.
|
|
|
|
|
*
|
|
|
|
|
* @param query An identical query corresponding to one passed to -addUserListenerWithQuery.
|
|
|
|
|
*/
|
2019-08-02 11:35:33 -07:00
|
|
|
- (void)removeUserListenerWithQuery:(const core::Query &)query;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
2021-03-16 17:07:47 -04:00
|
|
|
/**
|
|
|
|
|
* Loads a Firestore bundle captured in `reader` into the local storage.
|
|
|
|
|
*
|
|
|
|
|
* Resulting events are captured and made available via the capturedEventsSinceLastCall method.
|
|
|
|
|
*
|
|
|
|
|
* @param reader An object to read from the underlying input stream of the bundle.
|
|
|
|
|
* @param task An object to report loading progress and result.
|
|
|
|
|
*/
|
|
|
|
|
- (void)loadBundleWithReader:(std::shared_ptr<bundle::BundleReader>)reader
|
|
|
|
|
task:(std::shared_ptr<api::LoadBundleTask>)task;
|
|
|
|
|
|
2017-10-03 08:55:22 -07:00
|
|
|
/**
|
|
|
|
|
* Delivers a WatchChange RPC to the FSTSyncEngine as if it were received from the backend watch
|
|
|
|
|
* service, either in response to addUserListener: or removeUserListener calls or because the
|
|
|
|
|
* simulated backend has new data.
|
|
|
|
|
*
|
|
|
|
|
* Resulting events are captured and made available via the capturedEventsSinceLastCall method.
|
|
|
|
|
*
|
|
|
|
|
* @param change Any type of watch change
|
|
|
|
|
* @param snapshot A snapshot version to attach, if applicable. This should be sent when
|
|
|
|
|
* simulating the server having sent a complete snapshot.
|
|
|
|
|
*/
|
2020-02-15 14:34:38 -08:00
|
|
|
- (void)receiveWatchChange:(const remote::WatchChange &)change
|
|
|
|
|
snapshotVersion:(const model::SnapshotVersion &)snapshot;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delivers a watch stream error as if the Streaming Watch backend has generated some kind of error.
|
|
|
|
|
*
|
|
|
|
|
* @param errorCode A FIRFirestoreErrorCode value, from FIRFirestoreErrors.h
|
|
|
|
|
* @param userInfo Any additional details that the server might have sent along with the error.
|
|
|
|
|
* For the moment this is effectively unused, but is logged.
|
|
|
|
|
*/
|
|
|
|
|
- (void)receiveWatchStreamError:(int)errorCode userInfo:(NSDictionary<NSString *, id> *)userInfo;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Performs a mutation against the FSTSyncEngine as if the user had written the mutation through
|
|
|
|
|
* the API.
|
|
|
|
|
*
|
|
|
|
|
* Also retains the mutation so that the driver can validate that the sync engine sent the mutation
|
|
|
|
|
* to the remote store before receiveWatchChange:snapshotVersion: and receiveWriteError:userInfo:
|
|
|
|
|
* events are processed.
|
|
|
|
|
*
|
|
|
|
|
* @param mutation Any type of valid mutation.
|
|
|
|
|
*/
|
2019-08-14 23:18:47 -07:00
|
|
|
- (void)writeUserMutation:(model::Mutation)mutation;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delivers a write error as if the Streaming Write backend has generated some kind of error.
|
|
|
|
|
*
|
|
|
|
|
* For the moment write errors are usually must be in response to a mutation that has been written
|
|
|
|
|
* with writeUserMutation:. Spontaneously errors due to idle timeout, server restart, or credential
|
|
|
|
|
* expiration aren't yet supported.
|
|
|
|
|
*
|
|
|
|
|
* @param errorCode A FIRFirestoreErrorCode value, from FIRFirestoreErrors.h
|
|
|
|
|
* @param userInfo Any additional details that the server might have sent along with the error.
|
|
|
|
|
* For the moment this is effectively unused, but is logged.
|
2018-08-03 17:06:04 -07:00
|
|
|
* @param keepInQueue Whether to keep the write in the write queue as it will be retried.
|
2017-10-03 08:55:22 -07:00
|
|
|
*/
|
|
|
|
|
- (FSTOutstandingWrite *)receiveWriteError:(int)errorCode
|
2018-08-03 17:06:04 -07:00
|
|
|
userInfo:(NSDictionary<NSString *, id> *)userInfo
|
|
|
|
|
keepInQueue:(BOOL)keepInQueue;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delivers a write acknowledgement as if the Streaming Write backend has acknowledged a write with
|
|
|
|
|
* the snapshot version at which the write was committed.
|
|
|
|
|
*
|
|
|
|
|
* @param commitVersion The snapshot version at which the simulated server has committed
|
|
|
|
|
* the mutation. Snapshot versions must be monotonically increasing.
|
|
|
|
|
* @param mutationResults The mutation results for the write that is being acked.
|
|
|
|
|
*/
|
2020-02-15 14:34:38 -08:00
|
|
|
- (FSTOutstandingWrite *)receiveWriteAckWithVersion:(const model::SnapshotVersion &)commitVersion
|
|
|
|
|
mutationResults:
|
|
|
|
|
(std::vector<model::MutationResult>)mutationResults;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A count of the mutations written to the write stream by the FSTSyncEngine, but not yet
|
|
|
|
|
* acknowledged via receiveWriteError: or receiveWriteAckWithVersion:mutationResults.
|
|
|
|
|
*/
|
|
|
|
|
@property(nonatomic, readonly) int sentWritesCount;
|
|
|
|
|
|
2017-11-08 17:04:41 -08:00
|
|
|
/**
|
|
|
|
|
* A count of the total number of requests sent to the write stream since the beginning of the test
|
|
|
|
|
* case.
|
|
|
|
|
*/
|
|
|
|
|
@property(nonatomic, readonly) int writeStreamRequestCount;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A count of the total number of requests sent to the watch stream since the beginning of the test
|
|
|
|
|
* case.
|
|
|
|
|
*/
|
|
|
|
|
@property(nonatomic, readonly) int watchStreamRequestCount;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Disables RemoteStore's network connection and shuts down all streams.
|
|
|
|
|
*/
|
|
|
|
|
- (void)disableNetwork;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enables RemoteStore's network connection.
|
|
|
|
|
*/
|
|
|
|
|
- (void)enableNetwork;
|
|
|
|
|
|
2018-03-05 09:49:41 -08:00
|
|
|
/**
|
2018-11-18 17:49:32 -05:00
|
|
|
* Runs a pending timer callback on the worker queue.
|
2018-03-05 09:49:41 -08:00
|
|
|
*/
|
2021-11-02 22:31:45 -04:00
|
|
|
- (void)runTimer:(firebase::firestore::util::TimerId)timerID;
|
2018-03-05 09:49:41 -08:00
|
|
|
|
2023-04-18 13:00:05 -04:00
|
|
|
/**
|
|
|
|
|
* Triggers a LRU GC run with given cache threshold.
|
|
|
|
|
*/
|
|
|
|
|
- (void)triggerLruGC:(NSNumber *)threshold;
|
|
|
|
|
|
2017-10-03 08:55:22 -07:00
|
|
|
/**
|
|
|
|
|
* Switches the FSTSyncEngine to a new user. The test driver tracks the outstanding mutations for
|
|
|
|
|
* each user, so future receiveWriteAck/Error operations will validate the write sent to the mock
|
|
|
|
|
* datastore matches the next outstanding write for that user.
|
|
|
|
|
*/
|
2021-10-07 14:16:58 -06:00
|
|
|
- (void)changeUser:(const credentials::User &)user;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
2018-08-03 17:06:04 -07:00
|
|
|
/**
|
|
|
|
|
* Drains the client's dispatch queue.
|
|
|
|
|
*/
|
|
|
|
|
- (void)drainQueue;
|
|
|
|
|
|
2017-10-03 08:55:22 -07:00
|
|
|
/**
|
|
|
|
|
* Returns all query events generated by the FSTSyncEngine in response to the event injection
|
|
|
|
|
* methods called previously. The events are cleared after each invocation of this method.
|
|
|
|
|
*/
|
|
|
|
|
- (NSArray<FSTQueryEvent *> *)capturedEventsSinceLastCall;
|
|
|
|
|
|
2018-08-03 17:06:04 -07:00
|
|
|
/**
|
|
|
|
|
* Returns the names of the documents that the client acknowledged since the last call to this
|
|
|
|
|
* method. The keys are cleared after each invocation of this method.
|
|
|
|
|
*/
|
|
|
|
|
- (NSArray<NSString *> *)capturedAcknowledgedWritesSinceLastCall;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the names of the documents that the client rejected since the last call to this
|
|
|
|
|
* method. The keys are cleared after each invocation of this method.
|
|
|
|
|
*/
|
|
|
|
|
- (NSArray<NSString *> *)capturedRejectedWritesSinceLastCall;
|
|
|
|
|
|
2020-04-15 12:01:09 -04:00
|
|
|
/** The current set of documents in limbo with active targets. */
|
|
|
|
|
- (std::map<model::DocumentKey, model::TargetId>)activeLimboDocumentResolutions;
|
|
|
|
|
|
|
|
|
|
/** The current set of documents in limbo that are enqueued for resolution. */
|
2021-02-12 10:34:14 -05:00
|
|
|
- (std::vector<model::DocumentKey>)enqueuedLimboDocumentResolutions;
|
2018-03-27 14:33:39 -04:00
|
|
|
|
2020-04-07 10:10:26 -04:00
|
|
|
/** The expected set of documents in limbo with an active target. */
|
|
|
|
|
- (const model::DocumentKeySet &)expectedActiveLimboDocuments;
|
2018-12-10 11:57:08 -08:00
|
|
|
|
2020-04-07 10:10:26 -04:00
|
|
|
/** Sets the expected set of documents in limbo with an active target. */
|
|
|
|
|
- (void)setExpectedActiveLimboDocuments:(model::DocumentKeySet)docs;
|
2018-12-10 11:57:08 -08:00
|
|
|
|
2020-04-15 12:01:09 -04:00
|
|
|
/** The expected set of documents in limbo that are enqueued for resolution. */
|
|
|
|
|
- (const model::DocumentKeySet &)expectedEnqueuedLimboDocuments;
|
|
|
|
|
|
|
|
|
|
/** Sets the expected set of documents in limbo that are enqueued for resolution. */
|
|
|
|
|
- (void)setExpectedEnqueuedLimboDocuments:(model::DocumentKeySet)docs;
|
|
|
|
|
|
2017-10-03 08:55:22 -07:00
|
|
|
/**
|
|
|
|
|
* The writes that have been sent to the FSTSyncEngine via writeUserMutation: but not yet
|
|
|
|
|
* acknowledged by calling receiveWriteAck/Error:. They are tracked per-user.
|
|
|
|
|
*
|
|
|
|
|
* It is mostly an implementation detail used internally to validate that the writes sent to the
|
|
|
|
|
* mock backend by the FSTSyncEngine match the user mutations that initiated them.
|
|
|
|
|
*
|
|
|
|
|
* It is exposed specifically for use with the
|
|
|
|
|
* initWithPersistence:GCEnabled:outstandingWrites: initializer to test persistence
|
2019-09-12 14:28:10 -07:00
|
|
|
* scenarios where the FSTSyncEngine is restarted while the Persistence implementation still has
|
2017-10-03 08:55:22 -07:00
|
|
|
* outstanding persisted mutations.
|
|
|
|
|
*
|
|
|
|
|
* Note: The size of the list for the current user will generally be the same as
|
2019-02-08 14:37:42 -05:00
|
|
|
* sentWritesCount, but not necessarily, since the `RemoteStore` limits the number of
|
2017-10-03 08:55:22 -07:00
|
|
|
* outstanding writes to the backend at a given time.
|
|
|
|
|
*/
|
2018-02-15 17:23:08 -05:00
|
|
|
@property(nonatomic, assign, readonly) const FSTOutstandingWriteQueues &outstandingWrites;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
|
|
|
|
/** The current user for the FSTSyncEngine; determines which mutation queue is active. */
|
2021-10-07 14:16:58 -06:00
|
|
|
@property(nonatomic, assign, readonly) const credentials::User ¤tUser;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
2020-09-22 18:48:04 -07:00
|
|
|
/**
|
|
|
|
|
* The number of waitForPendingWrites events that have been received.
|
|
|
|
|
*/
|
|
|
|
|
@property(nonatomic, readonly) int waitForPendingWritesEvents;
|
2021-03-16 17:07:47 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The DatabaseInfo of the Firestore instance.
|
|
|
|
|
*/
|
|
|
|
|
@property(nonatomic, readonly) const core::DatabaseInfo &databaseInfo;
|
2020-09-22 18:48:04 -07:00
|
|
|
|
|
|
|
|
- (void)incrementWaitForPendingWritesEvents;
|
|
|
|
|
|
|
|
|
|
- (void)resetWaitForPendingWritesEvents;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register a new waitForPendingWrites() callback.
|
|
|
|
|
*/
|
|
|
|
|
- (void)waitForPendingWrites;
|
|
|
|
|
|
2019-09-20 14:15:57 -04:00
|
|
|
/**
|
|
|
|
|
* The number of snapshots-in-sync events that have been received.
|
|
|
|
|
*/
|
|
|
|
|
@property(nonatomic, readonly) int snapshotsInSyncEvents;
|
|
|
|
|
|
|
|
|
|
- (void)incrementSnapshotsInSyncEvents;
|
|
|
|
|
|
|
|
|
|
- (void)resetSnapshotsInSyncEvents;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a snpahots-in-sync listener to the event manager and keeps track of it so that it
|
|
|
|
|
* can be easily removed later.
|
|
|
|
|
*/
|
|
|
|
|
- (void)addSnapshotsInSyncListener;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes the snapshots-in-sync listener from the event manager.
|
|
|
|
|
*/
|
|
|
|
|
- (void)removeSnapshotsInSyncListener;
|
|
|
|
|
|
2017-10-03 08:55:22 -07:00
|
|
|
/** The set of active targets as observed on the watch stream. */
|
2020-02-15 14:34:38 -08:00
|
|
|
- (const std::unordered_map<model::TargetId, local::TargetData> &)activeTargets;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
|
|
|
|
/** The expected set of active targets, keyed by target ID. */
|
2020-01-08 12:04:28 -05:00
|
|
|
- (const ActiveTargetMap &)expectedActiveTargets;
|
2019-01-23 17:26:49 -05:00
|
|
|
|
2020-01-08 12:04:28 -05:00
|
|
|
- (void)setExpectedActiveTargets:(ActiveTargetMap)targets;
|
2017-10-03 08:55:22 -07:00
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|