-
Notifications
You must be signed in to change notification settings - Fork 578
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
Http client in Firebase Segmentation SDK to call backend service. #573
Conversation
…k into arete-floc
…k into arete-floc
…k into arete-floc
…k into arete-floc
cache and update to Firebase Segmentation backend. CL also contains unit tests. (The http client is not implemented yet.)
…k into arete-floc
…k into arete-floc
…k into arete-floc
…k into arete-floc
…k into arete-floc
2. Some fixes for the http request format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, given your limited needs in terms of http, I'd strongly suggest you consider using HttpUrlConnection instead of okhttp
...ntation/src/main/java/com/google/firebase/segmentation/remote/SegmentationServiceClient.java
Outdated
Show resolved
Hide resolved
entire synchronous code block in async task.
Changed okhttpclient to httpsUrlConnection |
...ntation/src/main/java/com/google/firebase/segmentation/remote/SegmentationServiceClient.java
Outdated
Show resolved
Hide resolved
...ntation/src/main/java/com/google/firebase/segmentation/remote/SegmentationServiceClient.java
Outdated
Show resolved
Hide resolved
@@ -36,12 +39,14 @@ | |||
private final FirebaseInstanceId firebaseInstanceId; | |||
private final CustomInstallationIdCache localCache; | |||
private final SegmentationServiceClient backendServiceClient; | |||
private final Executor executor; | |||
|
|||
FirebaseSegmentation(FirebaseApp firebaseApp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this constructor delegate to the one below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
} | ||
TaskCompletionSource<Void> taskCompletionSource = new TaskCompletionSource<>(); | ||
|
||
executor.execute( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 points:
- There is a dedicated
Tasks.call(executor, callable)
to achieve this effect - Consider extracting the lambda below into its own (private) method that you can annotate with
@WorkerThread
This applies to the here and throughout as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good learning!
Done
The proto is defined in https://cs.corp.google.com/piper///depot/google3/google/firebase/segmentation/v1alpha/segmentation_service.proto