Skip to content

C++ migration: eliminate FSTRemoteStore #2338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 147 commits into from
Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
76b206b
Remove extra imports and includes
var-const Jan 15, 2019
7dcb9ae
Port
var-const Jan 15, 2019
88ba1a7
Forgotten method
var-const Jan 15, 2019
895bf45
style.sh
var-const Jan 15, 2019
b66c5d2
Forgotten the main part!
var-const Jan 15, 2019
3f5fdae
Fixup unit tests
var-const Jan 15, 2019
5ce04b8
Wip
var-const Jan 16, 2019
3dc3170
Step back
var-const Jan 18, 2019
9d1f931
Core compiles
var-const Jan 18, 2019
7ea798e
Merge branch 'master' into varconst/fst-watch-change
var-const Jan 18, 2019
84842be
quick fix
var-const Jan 18, 2019
e5132be
Test helpers
var-const Jan 18, 2019
6c85090
MockDatastore
var-const Jan 18, 2019
f7a90b5
FSTLocalStoreTests
var-const Jan 18, 2019
267963f
wip
var-const Jan 18, 2019
60a5726
wip
var-const Jan 18, 2019
dd9d98d
FSTRemoveEventTests
var-const Jan 18, 2019
aec3f54
FSTSerializerBetaTests
var-const Jan 19, 2019
b012929
wip
var-const Jan 19, 2019
1da0672
wip
var-const Jan 21, 2019
e0f77f2
wip
var-const Jan 21, 2019
df5cd00
wip
var-const Jan 21, 2019
5d3313a
wip
var-const Jan 21, 2019
31e5f3d
wip
var-const Jan 21, 2019
0637243
Ship it!
var-const Jan 21, 2019
26b39c7
use changes
var-const Jan 21, 2019
2cab650
quick fix
var-const Jan 21, 2019
ca88d8c
Unit tests pass
var-const Jan 21, 2019
2c0a7ef
style.sh
var-const Jan 21, 2019
52b131d
Small fixes
var-const Jan 21, 2019
35ce8cc
Get rid of ids alias
var-const Jan 21, 2019
8230fbb
Fixes
var-const Jan 21, 2019
ceb3bee
Move the test
var-const Jan 21, 2019
dd617de
Restore nooutstandingresponses variable
var-const Jan 21, 2019
9d80eea
Small fixes
var-const Jan 21, 2019
836d4de
style.sh
var-const Jan 21, 2019
134acaf
Review feedback
var-const Jan 22, 2019
f8dd5a5
Review feedback
var-const Jan 22, 2019
c02df53
comment
var-const Jan 22, 2019
ce17913
Appease linter
var-const Jan 22, 2019
a87cf7e
Initial
var-const Jan 22, 2019
d6a137a
wip
var-const Jan 23, 2019
1c99679
wip
var-const Jan 23, 2019
b2e0dd1
Initial
var-const Jan 23, 2019
e076f25
style.sh
var-const Jan 23, 2019
359d938
Merge branch 'master' into varconst/fst-document-view-change-type
var-const Jan 23, 2019
4b7c6a7
forgotten file
var-const Jan 23, 2019
7164e2b
Merge branch 'varconst/fst-document-view-change-type' into varconst/f…
var-const Jan 23, 2019
48fbab6
pt. 1 compiles
var-const Jan 23, 2019
0325248
Wip
var-const Jan 23, 2019
acbc626
wip
var-const Jan 24, 2019
b178b00
Merge branch 'master' into varconst/fst-watch-change-aggregator
var-const Jan 24, 2019
78395d8
In theory, all methods implemented
var-const Jan 24, 2019
4fee491
wip
var-const Jan 24, 2019
626efec
Almost compiles
var-const Jan 24, 2019
66db96a
Merge branch 'master' into varconst/fst-watch-change-aggregator
var-const Jan 24, 2019
d5defb1
appease linter
var-const Jan 24, 2019
52b2171
Bring method order into compliance
var-const Jan 24, 2019
e5fcf94
Compliacne, pt.2
var-const Jan 24, 2019
7a48512
core compiles
var-const Jan 25, 2019
66d8af2
unit tests compile
var-const Jan 26, 2019
594a841
Fix unit test -- all pass
var-const Jan 26, 2019
77d9cd7
style.sh
var-const Jan 26, 2019
fdf05a7
Review feedback
var-const Jan 26, 2019
a910ccd
Merge branch 'varconst/fst-watch-change-aggregator' into varconst/fst…
var-const Jan 26, 2019
c71a541
undo formatting
var-const Jan 26, 2019
24a745e
fix
var-const Jan 26, 2019
142f08c
Merge branch 'varconst/fst-watch-change-aggregator' into varconst/fst…
var-const Jan 27, 2019
e402e8b
Merge branch 'master' into varconst/fst-target-change
var-const Jan 27, 2019
e3dd85e
Temp code
var-const Jan 27, 2019
1eb4096
Implementation
var-const Jan 28, 2019
4147c3d
Updating references wip (FSTRemoteEventsTests still to do)
var-const Jan 28, 2019
3b3b012
Unit tests compile
var-const Jan 28, 2019
f1140d9
Unit tests compile and pass
var-const Jan 28, 2019
7ee766f
style.sh
var-const Jan 28, 2019
f00494a
Minor improvements
var-const Jan 28, 2019
766e940
Review feedback
var-const Jan 29, 2019
68ced12
Merge branch 'varconst/fst-target-change' into varconst/fst-remote-ev…
var-const Jan 29, 2019
90450fd
Initial implementation
var-const Jan 29, 2019
ed7ee52
Updating references
var-const Jan 29, 2019
ab6d050
Merge branch 'master' into varconst/fst-remote-event2
var-const Jan 29, 2019
920a921
All compiles
var-const Jan 29, 2019
3d509ec
style.sh
var-const Jan 29, 2019
b2d8ce4
Minor consistency changes
var-const Jan 29, 2019
355ced0
Skeleton
var-const Jan 29, 2019
df4c82e
Pseudochange
var-const Jan 29, 2019
9b494ee
Undo pseudochange
var-const Jan 29, 2019
c5a82f9
unstyle
var-const Jan 29, 2019
65b6ae2
Review feedback
var-const Jan 30, 2019
055372e
Merge branch 'varconst/fst-remote-event2' into varconst/fst-online-st…
var-const Jan 30, 2019
9435faf
Merge branch 'master' into varconst/fst-online-state-tracker
var-const Jan 30, 2019
151f99d
Change extension
var-const Jan 30, 2019
06947a5
style
var-const Jan 30, 2019
26bb8a9
wip
var-const Jan 30, 2019
61f821e
Redundant
var-const Jan 30, 2019
448b1fc
wip
var-const Jan 30, 2019
a7d99ae
wip
var-const Jan 30, 2019
286850f
Merge branch 'varconst/fst-online-state-tracker' into varconst/fst-re…
var-const Jan 30, 2019
6119d54
core actually compiles
var-const Jan 30, 2019
8fa4e74
style.sh
var-const Jan 30, 2019
6702112
wip
var-const Jan 31, 2019
4ec169e
unit tests compile
var-const Jan 31, 2019
6db2ee9
style.sh
var-const Jan 31, 2019
463b652
accidental
var-const Jan 31, 2019
dba5e70
small fixes
var-const Jan 31, 2019
97229a8
initial
var-const Feb 1, 2019
5266f7c
initial cont.
var-const Feb 1, 2019
43c575a
Merge branch 'master' into varconst/fst-online-state-tracker
var-const Feb 1, 2019
53f00fc
Compiles!
var-const Feb 1, 2019
1858aae
all tests pass
var-const Feb 1, 2019
4589e1f
style.sh
var-const Feb 1, 2019
3025ca3
Merge branch 'varconst/fst-online-state-tracker' into varconst/fst-re…
var-const Feb 1, 2019
882a137
Merge branch 'master' into varconst/fst-remote-store1
var-const Feb 1, 2019
5f1ac4b
Merge branch 'varconst/fst-remote-store1' into varconst/fst-remote-st…
var-const Feb 1, 2019
28e0689
android method order
var-const Feb 1, 2019
c803f61
web method order
var-const Feb 1, 2019
aa18e6c
rename
var-const Feb 1, 2019
ce0d114
undo
var-const Feb 1, 2019
771b6d2
Compiles!
var-const Feb 1, 2019
318debc
Review feedback
var-const Feb 1, 2019
0e477c2
Merge branch 'varconst/fst-remote-store1' into varconst/fst-remote-st…
var-const Feb 1, 2019
924b455
Review feedback
var-const Feb 1, 2019
39d980c
Merge branch 'varconst/fst-remote-store2' into varconst/fst-remote-st…
var-const Feb 1, 2019
cd8107b
Small fixes
var-const Feb 1, 2019
6cb2693
Compiles!
var-const Feb 1, 2019
af88702
style.sh
var-const Feb 1, 2019
33da753
fix weird bug
var-const Feb 2, 2019
808e169
Merge branch 'varconst/fst-remote-store1' into varconst/fst-remote-st…
var-const Feb 2, 2019
5f54216
Merge branch 'varconst/fst-remote-store2' into varconst/fst-remote-st…
var-const Feb 2, 2019
5de4789
compilation fix
var-const Feb 2, 2019
971954c
Merge branch 'varconst/fst-remote-store3' into varconst/fst-remote-st…
var-const Feb 2, 2019
a196232
Merge branch 'master' into varconst/fst-remote-store2
var-const Feb 6, 2019
217a47f
Review feedback
var-const Feb 7, 2019
144dba5
Merge branch 'varconst/fst-remote-store2' into varconst/fst-remote-st…
var-const Feb 7, 2019
5043c6c
Merge branch 'varconst/fst-remote-store3' into varconst/fst-remote-st…
var-const Feb 7, 2019
fa1082e
Fix
var-const Feb 7, 2019
60a5f06
Merge branch 'varconst/fst-remote-store2' into varconst/fst-remote-st…
var-const Feb 7, 2019
38dce72
Merge branch 'master' into varconst/fst-remote-store3
var-const Feb 7, 2019
867f202
pseudocommit
var-const Feb 7, 2019
ec445f0
pseudocommit
var-const Feb 7, 2019
4a7e460
Fix bug
var-const Feb 7, 2019
9e7706e
Merge branch 'varconst/fst-remote-store3' into varconst/fst-remote-st…
var-const Feb 7, 2019
0dd39c3
Merge branch 'master' into varconst/fst-remote-store4
var-const Feb 7, 2019
edf828c
pseudocommit
var-const Feb 7, 2019
6ffd290
pseudocommit
var-const Feb 7, 2019
3cf1447
Fix compilation
var-const Feb 7, 2019
6263612
comment tweak
var-const Feb 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions Firestore/Example/Tests/Integration/FSTDatastoreTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#import "Firestore/Source/Model/FSTFieldValue.h"
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Model/FSTMutationBatch.h"
#import "Firestore/Source/Remote/FSTRemoteStore.h"

#import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h"

Expand All @@ -41,6 +40,7 @@
#include "Firestore/core/src/firebase/firestore/model/precondition.h"
#include "Firestore/core/src/firebase/firestore/remote/datastore.h"
#include "Firestore/core/src/firebase/firestore/remote/remote_event.h"
#include "Firestore/core/src/firebase/firestore/remote/remote_store.h"
#include "Firestore/core/src/firebase/firestore/util/async_queue.h"
#include "Firestore/core/src/firebase/firestore/util/executor_libdispatch.h"
#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
Expand All @@ -60,15 +60,12 @@
using firebase::firestore::remote::Datastore;
using firebase::firestore::remote::GrpcConnection;
using firebase::firestore::remote::RemoteEvent;
using firebase::firestore::remote::RemoteStore;
using firebase::firestore::util::AsyncQueue;
using firebase::firestore::util::ExecutorLibdispatch;

NS_ASSUME_NONNULL_BEGIN

@interface FSTRemoteStore (Tests)
- (void)addBatchToWritePipeline:(FSTMutationBatch *)batch;
@end

#pragma mark - FSTRemoteStoreEventCapture

@interface FSTRemoteStoreEventCapture : NSObject <FSTRemoteSyncer>
Expand Down Expand Up @@ -163,7 +160,7 @@ @implementation FSTDatastoreTests {

DatabaseInfo _databaseInfo;
std::shared_ptr<Datastore> _datastore;
FSTRemoteStore *_remoteStore;
std::unique_ptr<RemoteStore> _remoteStore;
}

- (void)setUp {
Expand All @@ -185,18 +182,16 @@ - (void)setUp {
_testWorkerQueue = absl::make_unique<AsyncQueue>(absl::make_unique<ExecutorLibdispatch>(queue));
_datastore = std::make_shared<Datastore>(_databaseInfo, _testWorkerQueue.get(), &_credentials);

_remoteStore = [[FSTRemoteStore alloc] initWithLocalStore:_localStore
datastore:_datastore
workerQueue:_testWorkerQueue.get()
onlineStateHandler:[](OnlineState) {}];
_remoteStore = absl::make_unique<RemoteStore>(_localStore, _datastore, _testWorkerQueue.get(),
[](OnlineState) {});

_testWorkerQueue->Enqueue([=] { [_remoteStore start]; });
_testWorkerQueue->Enqueue([=] { _remoteStore->Start(); });
}

- (void)tearDown {
XCTestExpectation *completion = [self expectationWithDescription:@"shutdown"];
_testWorkerQueue->Enqueue([=] {
[_remoteStore shutdown];
_remoteStore->Shutdown();
[completion fulfill];
});
[self awaitExpectations];
Expand All @@ -219,17 +214,17 @@ - (void)testStreamingWrite {
FSTRemoteStoreEventCapture *capture = [[FSTRemoteStoreEventCapture alloc] initWithTestCase:self];
[capture expectWriteEventWithDescription:@"write mutations"];

[_remoteStore setSyncEngine:capture];
_remoteStore->set_sync_engine(capture);

FSTSetMutation *mutation = [self setMutation];
FSTMutationBatch *batch = [[FSTMutationBatch alloc] initWithBatchID:23
localWriteTime:[FIRTimestamp timestamp]
mutations:@[ mutation ]];
_testWorkerQueue->Enqueue([=] {
[_remoteStore addBatchToWritePipeline:batch];
_remoteStore->AddToWritePipeline(batch);
// The added batch won't be written immediately because write stream wasn't yet open --
// trigger its opening.
[_remoteStore fillWritePipeline];
_remoteStore->FillWritePipeline();
});

[self awaitExpectations];
Expand Down
4 changes: 1 addition & 3 deletions Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <unordered_map>
#include <vector>

#import "Firestore/Source/Remote/FSTRemoteStore.h"

#include "Firestore/core/src/firebase/firestore/auth/user.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/model/document_key_set.h"
Expand Down Expand Up @@ -286,7 +284,7 @@ typedef std::unordered_map<firebase::firestore::auth::User,
* outstanding persisted mutations.
*
* Note: The size of the list for the current user will generally be the same as
* sentWritesCount, but not necessarily, since the FSTRemoteStore limits the number of
* sentWritesCount, but not necessarily, since the `RemoteStore` limits the number of
* outstanding writes to the backend at a given time.
*/
@property(nonatomic, assign, readonly) const FSTOutstandingWriteQueues &outstandingWrites;
Expand Down
33 changes: 17 additions & 16 deletions Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/remote/remote_store.h"
#include "Firestore/core/src/firebase/firestore/util/async_queue.h"
#include "Firestore/core/src/firebase/firestore/util/executor_libdispatch.h"
#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
Expand All @@ -58,6 +59,7 @@
using firebase::firestore::model::SnapshotVersion;
using firebase::firestore::model::TargetId;
using firebase::firestore::remote::MockDatastore;
using firebase::firestore::remote::RemoteStore;
using firebase::firestore::remote::WatchChange;
using firebase::firestore::util::AsyncQueue;
using firebase::firestore::util::TimerId;
Expand Down Expand Up @@ -85,7 +87,6 @@ @interface FSTSyncEngineTestDriver ()
#pragma mark - Parts of the Firestore system that the spec tests need to control.

@property(nonatomic, strong, readonly) FSTEventManager *eventManager;
@property(nonatomic, strong, readonly) FSTRemoteStore *remoteStore;
@property(nonatomic, strong, readonly) FSTLocalStore *localStore;
@property(nonatomic, strong, readonly) FSTSyncEngine *syncEngine;
@property(nonatomic, strong, readonly) id<FSTPersistence> persistence;
Expand All @@ -112,6 +113,8 @@ @interface FSTSyncEngineTestDriver ()
@implementation FSTSyncEngineTestDriver {
std::unique_ptr<AsyncQueue> _workerQueue;

std::unique_ptr<RemoteStore> _remoteStore;

std::unordered_map<TargetId, FSTQueryData *> _expectedActiveTargets;

// ivar is declared as mutable.
Expand Down Expand Up @@ -153,19 +156,17 @@ - (instancetype)initWithPersistence:(id<FSTPersistence>)persistence

_datastore =
std::make_shared<MockDatastore>(_databaseInfo, _workerQueue.get(), &_credentialProvider);
_remoteStore =
[[FSTRemoteStore alloc] initWithLocalStore:_localStore
datastore:_datastore
workerQueue:_workerQueue.get()
onlineStateHandler:[self](OnlineState onlineState) {
[self.syncEngine applyChangedOnlineState:onlineState];
[self.eventManager applyChangedOnlineState:onlineState];
}];
_remoteStore = absl::make_unique<RemoteStore>(
_localStore, _datastore, _workerQueue.get(), [self](OnlineState onlineState) {
[self.syncEngine applyChangedOnlineState:onlineState];
[self.eventManager applyChangedOnlineState:onlineState];
});
;

_syncEngine = [[FSTSyncEngine alloc] initWithLocalStore:_localStore
remoteStore:_remoteStore
remoteStore:_remoteStore.get()
initialUser:initialUser];
[_remoteStore setSyncEngine:_syncEngine];
_remoteStore->set_sync_engine(_syncEngine);
_eventManager = [FSTEventManager eventManagerWithSyncEngine:_syncEngine];

// Set up internal event tracking for the spec tests.
Expand Down Expand Up @@ -209,7 +210,7 @@ - (void)drainQueue {
- (void)start {
_workerQueue->EnqueueBlocking([&] {
[self.localStore start];
[self.remoteStore start];
_remoteStore->Start();
});
}

Expand All @@ -221,7 +222,7 @@ - (void)validateUsage {

- (void)shutdown {
_workerQueue->EnqueueBlocking([&] {
[self.remoteStore shutdown];
_remoteStore->Shutdown();
[self.persistence shutdown];
});
}
Expand Down Expand Up @@ -253,13 +254,13 @@ - (void)disableNetwork {
_workerQueue->EnqueueBlocking([&] {
// Make sure to execute all writes that are currently queued. This allows us
// to assert on the total number of requests sent before shutdown.
[self.remoteStore fillWritePipeline];
[self.remoteStore disableNetwork];
_remoteStore->FillWritePipeline();
_remoteStore->DisableNetwork();
});
}

- (void)enableNetwork {
_workerQueue->EnqueueBlocking([&] { [self.remoteStore enableNetwork]; });
_workerQueue->EnqueueBlocking([&] { _remoteStore->EnableNetwork(); });
}

- (void)runTimer:(TimerId)timerID {
Expand Down
1 change: 0 additions & 1 deletion Firestore/Source/Core/FSTEventManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#import <Foundation/Foundation.h>

#import "Firestore/Source/Core/FSTViewSnapshot.h"
#import "Firestore/Source/Remote/FSTRemoteStore.h"

#include "Firestore/core/src/firebase/firestore/model/types.h"

Expand Down
1 change: 0 additions & 1 deletion Firestore/Source/Core/FSTFirestoreClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#import "Firestore/Source/Core/FSTTypes.h"
#import "Firestore/Source/Core/FSTViewSnapshot.h"
#import "Firestore/Source/Remote/FSTRemoteStore.h"

#include "Firestore/core/src/firebase/firestore/auth/credentials_provider.h"
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
Expand Down
28 changes: 14 additions & 14 deletions Firestore/Source/Core/FSTFirestoreClient.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@
#import "Firestore/Source/Local/FSTMemoryPersistence.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTDocumentSet.h"
#import "Firestore/Source/Remote/FSTRemoteStore.h"
#import "Firestore/Source/Remote/FSTSerializerBeta.h"
#import "Firestore/Source/Util/FSTClasses.h"

#include "Firestore/core/src/firebase/firestore/auth/credentials_provider.h"
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/remote/datastore.h"
#include "Firestore/core/src/firebase/firestore/remote/remote_store.h"
#include "Firestore/core/src/firebase/firestore/util/async_queue.h"
#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/log.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
#include "absl/memory/memory.h"

namespace util = firebase::firestore::util;
using firebase::firestore::auth::CredentialsProvider;
Expand All @@ -64,6 +65,7 @@
using firebase::firestore::model::MaybeDocumentMap;
using firebase::firestore::model::OnlineState;
using firebase::firestore::remote::Datastore;
using firebase::firestore::remote::RemoteStore;
using firebase::firestore::util::Path;
using firebase::firestore::util::Status;
using firebase::firestore::util::AsyncQueue;
Expand Down Expand Up @@ -93,7 +95,6 @@ - (instancetype)initWithDatabaseInfo:(const DatabaseInfo &)databaseInfo
@property(nonatomic, strong, readonly) FSTEventManager *eventManager;
@property(nonatomic, strong, readonly) id<FSTPersistence> persistence;
@property(nonatomic, strong, readonly) FSTSyncEngine *syncEngine;
@property(nonatomic, strong, readonly) FSTRemoteStore *remoteStore;
@property(nonatomic, strong, readonly) FSTLocalStore *localStore;

// Does not own the CredentialsProvider instance.
Expand All @@ -110,6 +111,8 @@ @implementation FSTFirestoreClient {
*/
std::unique_ptr<AsyncQueue> _workerQueue;

std::unique_ptr<RemoteStore> _remoteStore;

std::unique_ptr<Executor> _userExecutor;
std::chrono::milliseconds _initialGcDelay;
std::chrono::milliseconds _regularGcDelay;
Expand Down Expand Up @@ -226,26 +229,23 @@ - (void)initializeWithUser:(const User &)user settings:(FIRFirestoreSettings *)s
auto datastore =
std::make_shared<Datastore>(*self.databaseInfo, _workerQueue.get(), _credentialsProvider);

_remoteStore = [[FSTRemoteStore alloc] initWithLocalStore:_localStore
datastore:std::move(datastore)
workerQueue:_workerQueue.get()
onlineStateHandler:[self](OnlineState onlineState) {
[self.syncEngine applyChangedOnlineState:onlineState];
}];
_remoteStore = absl::make_unique<RemoteStore>(
_localStore, std::move(datastore), _workerQueue.get(),
[self](OnlineState onlineState) { [self.syncEngine applyChangedOnlineState:onlineState]; });

_syncEngine = [[FSTSyncEngine alloc] initWithLocalStore:_localStore
remoteStore:_remoteStore
remoteStore:_remoteStore.get()
initialUser:user];

_eventManager = [FSTEventManager eventManagerWithSyncEngine:_syncEngine];

// Setup wiring for remote store.
[_remoteStore setSyncEngine:_syncEngine];
_remoteStore->set_sync_engine(_syncEngine);

// NOTE: RemoteStore depends on LocalStore (for persisting stream tokens, refilling mutation
// queue, etc.) so must be started after LocalStore.
[_localStore start];
[_remoteStore start];
_remoteStore->Start();
}

/**
Expand All @@ -270,7 +270,7 @@ - (void)credentialDidChangeWithUser:(const User &)user {

- (void)disableNetworkWithCompletion:(nullable FSTVoidErrorBlock)completion {
_workerQueue->Enqueue([self, completion] {
[self.remoteStore disableNetwork];
_remoteStore->DisableNetwork();
if (completion) {
self->_userExecutor->Execute([=] { completion(nil); });
}
Expand All @@ -279,7 +279,7 @@ - (void)disableNetworkWithCompletion:(nullable FSTVoidErrorBlock)completion {

- (void)enableNetworkWithCompletion:(nullable FSTVoidErrorBlock)completion {
_workerQueue->Enqueue([self, completion] {
[self.remoteStore enableNetwork];
_remoteStore->EnableNetwork();
if (completion) {
self->_userExecutor->Execute([=] { completion(nil); });
}
Expand All @@ -294,7 +294,7 @@ - (void)shutdownWithCompletion:(nullable FSTVoidErrorBlock)completion {
if (self->_lruCallback) {
self->_lruCallback.Cancel();
}
[self.remoteStore shutdown];
_remoteStore->Shutdown();
[self.persistence shutdown];
if (completion) {
self->_userExecutor->Execute([=] { completion(nil); });
Expand Down
7 changes: 3 additions & 4 deletions Firestore/Source/Core/FSTSyncEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
#import <Foundation/Foundation.h>

#import "Firestore/Source/Core/FSTTypes.h"
#import "Firestore/Source/Remote/FSTRemoteStore.h"

#include "Firestore/core/src/firebase/firestore/auth/user.h"
#include "Firestore/core/src/firebase/firestore/model/types.h"
#include "Firestore/core/src/firebase/firestore/remote/remote_store.h"
#include "Firestore/core/src/firebase/firestore/util/async_queue.h"

@class FSTLocalStore;
@class FSTMutation;
@class FSTQuery;
@class FSTRemoteStore;
@class FSTViewSnapshot;

using firebase::firestore::model::OnlineState;
Expand Down Expand Up @@ -63,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN

- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithLocalStore:(FSTLocalStore *)localStore
remoteStore:(FSTRemoteStore *)remoteStore
remoteStore:(firebase::firestore::remote::RemoteStore *)remoteStore
initialUser:(const firebase::firestore::auth::User &)user
NS_DESIGNATED_INITIALIZER;

Expand All @@ -74,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN

/**
* Initiates a new listen. The FSTLocalStore will be queried for initial data and the listen will
* be sent to the FSTRemoteStore to get remote data. The registered FSTSyncEngineDelegate will be
* be sent to the `RemoteStore` to get remote data. The registered FSTSyncEngineDelegate will be
* notified of resulting view snapshots and/or listen errors.
*
* @return the target ID assigned to the query.
Expand Down
Loading