Skip to content

gRPC: replace Objective-C implementation with the new C++ implementation #1968

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 32 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
805b673
gRPC: add support for SSL disabled to `GrpcConnection`.
var-const Oct 18, 2018
839f408
gRPC: make gRPC calls using the C++ implementation:
var-const Oct 18, 2018
a93b783
C++: port `MockWatchStream` and `MockWriteStream` to C++.
var-const Oct 18, 2018
4fe32a1
No longer generate Objective-C gRPC service definitions from protos.
var-const Oct 18, 2018
0ea6fcc
Remove all references to Objective-C gRPC client.
var-const Oct 18, 2018
21d30b6
Use local certificate for now
var-const Oct 22, 2018
7f60ad0
Fix/improve ASCII conversion
var-const Oct 22, 2018
feb0285
Review feedback
var-const Oct 22, 2018
8332a5f
style.sh
var-const Oct 22, 2018
ab6df2e
Appease linter
var-const Oct 22, 2018
9f9d94d
Undo accidental change
var-const Oct 22, 2018
555e1d8
missing word
var-const Oct 22, 2018
6f0d4e6
add comment
var-const Oct 22, 2018
84e454b
Remove leftover reference to Objective-C gRPC
var-const Oct 22, 2018
c96f670
More using declarations
var-const Oct 22, 2018
e2e53b0
typo
var-const Oct 22, 2018
1bcfc0f
Use Path instead of plain string
var-const Oct 22, 2018
2d68f12
Missed include
var-const Oct 22, 2018
80a938e
Remove redundant word
var-const Oct 22, 2018
9c1dec6
Remove ASCII conversion when loading certificates, it is not necessary
var-const Oct 23, 2018
d638062
Compilation fix
var-const Oct 23, 2018
abceb14
Review feedback
var-const Oct 23, 2018
dc872a7
Tweak comment
var-const Oct 23, 2018
c4d99d7
Move certificate to Firestore/etc/roots.pem
var-const Oct 23, 2018
90c3b43
Forgotten file
var-const Oct 24, 2018
cf856e6
Review feedback
var-const Oct 24, 2018
33555c9
Forgotten comment
var-const Oct 24, 2018
f1c8f5d
Fix test
var-const Oct 24, 2018
1a5acc7
Review feedback
var-const Oct 25, 2018
101b611
Fix flaky test
var-const Oct 25, 2018
1f6ee21
Merge branch 'master' into varconst/grpc-integr82
var-const Oct 25, 2018
348a924
Fix bad port
var-const Oct 25, 2018
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
3 changes: 2 additions & 1 deletion Firestore/Example/Tests/Integration/FSTDatastoreTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
using firebase::firestore::model::DocumentKeySet;
using firebase::firestore::model::Precondition;
using firebase::firestore::model::TargetId;
using firebase::firestore::remote::GrpcConnection;

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -162,7 +163,7 @@ - (void)setUp {
NSString *projectID = [FSTIntegrationTestCase projectID];
FIRFirestoreSettings *settings = [FSTIntegrationTestCase settings];
if (!settings.sslEnabled) {
[GRPCCall useInsecureConnectionsForHost:settings.host];
GrpcConnection::UseInsecureChannel(util::MakeString(settings.host));
}

DatabaseId database_id(util::MakeString(projectID), DatabaseId::kDefault);
Expand Down
10 changes: 3 additions & 7 deletions Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ - (void)tearDown {
[self shutdownFirestore:firestore];
}
} @finally {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[GRPCCall closeOpenConnections];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

GrpcConnection should take care of it now in Shutdown.

#pragma clang diagnostic pop
_firestores = nil;
[super tearDown];
}
Expand Down Expand Up @@ -165,9 +161,9 @@ + (void)setUpDefaults {
"Alternatively, if you're a Googler with a Hexa preproduction environment, run "
"setup_integration_tests.py to properly configure testing SSL certificates.");
}
[GRPCCall useTestCertsPath:certsPath testName:@"test_cert_2" forHost:defaultSettings.host];
GrpcConnection::UseTestCertificate([certsPath cStringUsingEncoding:NSASCIIStringEncoding],
"test_cert_2");
GrpcConnection::UseTestCertificate(
util::MakeString(defaultSettings.host),
util::MakeString(certsPath), "test_cert_2");
}

+ (NSString *)projectID {
Expand Down
26 changes: 10 additions & 16 deletions Firestore/Source/Remote/FSTDatastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@

#import <Foundation/Foundation.h>

#include <memory>
#include <vector>

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

#include "Firestore/core/src/firebase/firestore//remote/watch_stream.h"
#include "Firestore/core/src/firebase/firestore//remote/write_stream.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/model/document_key.h"
#include "Firestore/core/src/firebase/firestore/remote/datastore.h"
#include "absl/memory/memory.h"
#include "absl/strings/string_view.h"

@class FSTDispatchQueue;
Expand All @@ -32,9 +37,6 @@
@class FSTQueryData;
@class FSTSerializerBeta;
@class FSTWatchChange;
@class FSTWatchStream;
@class FSTWriteStream;
@class GRPCCall;
@class GRXWriter;

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -67,12 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
credentials // no passing ownership
NS_DESIGNATED_INITIALIZER;

/**
* Takes a dictionary of (HTTP) response headers and returns the set of whitelisted headers
* (for logging purposes).
*/
+ (NSDictionary<NSString *, NSString *> *)extractWhiteListedHeaders:
(NSDictionary<NSString *, NSString *> *)header;
- (void)shutdown;

/** Converts the error to a FIRFirestoreErrorDomain error. */
+ (NSError *)firestoreErrorForError:(NSError *)error;
Expand All @@ -83,11 +80,6 @@ NS_ASSUME_NONNULL_BEGIN
/** Returns YES if the given error indicates the RPC associated with it may not be retried. */
+ (BOOL)isPermanentWriteError:(NSError *)error;

/** Adds headers to the RPC including any OAuth access token if provided .*/
+ (void)prepareHeadersForRPC:(GRPCCall *)rpc
databaseID:(const firebase::firestore::model::DatabaseId *)databaseID
token:(const absl::string_view)token;

/** Looks up a list of documents in datastore. */
- (void)lookupDocuments:(const std::vector<firebase::firestore::model::DocumentKey> &)keys
completion:(FSTVoidMaybeDocumentArrayErrorBlock)completion;
Expand All @@ -97,10 +89,12 @@ NS_ASSUME_NONNULL_BEGIN
completion:(FSTVoidErrorBlock)completion;

/** Creates a new watch stream. */
- (FSTWatchStream *)createWatchStream;
- (std::shared_ptr<firebase::firestore::remote::WatchStream>)createWatchStreamWithDelegate:
(id<FSTWatchStreamDelegate>)delegate;

/** Creates a new write stream. */
- (FSTWriteStream *)createWriteStream;
- (std::shared_ptr<firebase::firestore::remote::WriteStream>)createWriteStreamWithDelegate:
(id<FSTWriteStreamDelegate>)delegate;

/** The name of the database and the backend. */
// Does not own this DatabaseInfo.
Expand Down
Loading