Skip to content
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

C++ migration: port watch stream-related part of FSTRemoteStore #2331

Merged
merged 111 commits into from
Feb 3, 2019

Conversation

var-const
Copy link
Contributor

@var-const var-const commented Jan 31, 2019

FSTRemoteStore is quite large, so to make the PRs more reviewable, I decided to have an intermediate state where only some of the methods are delegated to the C++ implementation.

@var-const var-const changed the base branch from master to varconst/fst-online-state-tracker January 31, 2019 22:32
std::function<void(model::OnlineState)> online_state_handler);

// TODO(varconst): remove the getters and setters
id<FSTRemoteSyncer> sync_engine() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are only necessary for the short transitional period, until the rest of FSTRemoteStore is migrated.

const model::SnapshotVersion& snapshot_version) override;
void OnWatchStreamClose(const util::Status& status) override;

// TODO(varconst): make the following methods private.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, these are only public until the rest of FSTRemoteStore is ported.

Copy link
Contributor

@zxu123 zxu123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


void RemoteStore::StartWatchStream() {
HARD_ASSERT(ShouldStartWatchStream(),
"StartWatchStream called when ShouldStartWatchStream: is false.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra : ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@var-const var-const changed the base branch from varconst/fst-online-state-tracker to master February 1, 2019 20:59
@@ -0,0 +1,216 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A suggestion (for later PRs): It's impossible to tell which lines in this file were "moved" from FSTRemoteStore, and which have been changed. Separating that into multiple commits (or even multiple PRs) would make reviewing much easier, since your reviewers could just skim the 'move' commit, and focus on the 'changed' stuff. (Especially useful when we're trying to keep the various ports consistent.)

*/
class WatchStream : public Stream {
public:
WatchStream(util::AsyncQueue* async_queue,
auth::CredentialsProvider* credentials_provider,
FSTSerializerBeta* serializer,
GrpcConnection* grpc_connection,
id<FSTWatchStreamDelegate> delegate);
WatchStreamCallback* callback);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding something like the following on the docstring:

@param callback Called when open/change/etc events occur on this WatchStream. Must not be null[*]. Must remain valid for the lifetime of this object.

[*] - Or 'Allowed to be null, in which case, the callbacks won't be invoked'.

(I really only care about the middle sentence; you could omit the other two, as they seem sufficiently obvious.)

Due to obj-c's nil dispatch, you'd get the [*] behaviour for free. We should decide whether we explicitly want this or not.

@@ -73,7 +73,7 @@
}

void WatchStream::NotifyStreamOpen() {
delegate_bridge_.NotifyDelegateOnOpen();
callback_->OnWatchStreamOpen();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Judging by the implementation, callback_ needs to be notnull. Consider asserting that in the ctor.

@@ -309,7 +311,7 @@ class RemoteEvent {
class WatchChangeAggregator {
public:
explicit WatchChangeAggregator(
id<FSTTargetMetadataProvider> target_metadata_provider)
TargetMetadataProvider* target_metadata_provider)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my other comment, consider making nullability explicit here. (i.e. docstring and notnull assertion if relevant.)

(Similarly here, you've technically changed the behaviour, since obj-c is quite happy to allow nils without segfaulting. But again, you're probably now more in line with the other ports, so this is entirely fine.)

Update: there's a bunch of other functions that just pipe this value through. Adding docstrings to those functions too might have some value in a public api, but personally, I think that would just be noise for internal apis. You could even omit the docstring here... the assertion itself would be a stronger form of documentation. :)

@rsgowman rsgowman assigned var-const and unassigned rsgowman Feb 1, 2019
@var-const var-const merged commit 456e8eb into master Feb 3, 2019
bstpierr added a commit that referenced this pull request Feb 8, 2019
* master: (27 commits)
  Pass FSTMutations using a vector (#2357)
  Update CI to use CocoaPods 1.6.0 (#2360)
  Add NS_ASSUME_NONNULL_NOTATION for game center sign in (#2359)
  C++ migration: make all methods of `FSTRemoteStore` delegate to C++ (#2337)
  C++ migration: port write stream-related part of `FSTRemoteStore` (#2335)
  Resolve hard dependency of GameKit (#2355)
  Update gRPC certificate bundles locations for Firebase 5.16 (#2353)
  Start pod lib lint CI for IAM (#2347)
  Update library name to `fire-fiam`. (#2352)
  Bump FirebaseAnalyticsInterop version  (#2315)
  Add IAM headless to CI (#2341)
  C++ migration: port watch stream-related part of `FSTRemoteStore` (#2331)
  Open source FIAM headless SDK (#2312)
  Port flaky test fix from web. (#2332)
  Make scripts/style.sh compatible with newer swiftformat versions (0.38) (#2334)
  C++ migration: port `FSTOnlineStateTracker` (#2325)
  Don't build fuzz tests target on Travis (#2330)
  Remove FSTMutationQueue (#2319)
  C++ migration: port `FSTRemoteEvent` (#2320)
  C++ migration: port `FSTTargetChange` (#2318)
  ...
@paulb777 paulb777 deleted the varconst/fst-remote-store1 branch April 13, 2019 16:00
@firebase firebase locked and limited conversation to collaborators Oct 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants