Conversation
sifmelcara
left a comment
There was a problem hiding this comment.
Most of the code came from other pending PRs?
Will do a review again after other PRs get merged
Yeah I have to build this PR on top of the other one in order to make the tests work. The relevant files in this PR are:
Sure, no problem! |
7e81906 to
fe7003f
Compare
src/core/ext/transport/binder/server/binder_server_credentials.cc
Outdated
Show resolved
Hide resolved
87f93f5 to
2346fc1
Compare
|
Hi Craig, can you take a look at the overall API design of the binder server? It should be easier to review now since the gigantic PR it depends on has been merged. Thanks! |
| // TODO(waynetu): This is part of the public API and should be moved to the | ||
| // include/ folder. |
There was a problem hiding this comment.
Can we just forward this header file in a header in include/ folder?
There was a problem hiding this comment.
This should be in the include/ folder, but since we haven't had a discussion with gRPC folks about these "binder pool" APIs, I think it'd be better if we first agree on the overall design and then move these headers to a proper place.
| // TODO(waynetu): Can these two functions be called in grpc_init() and | ||
| // grpc_shutdown()? | ||
| void grpc_endpoint_binder_pool_init(); | ||
| void grpc_endpoint_binder_pool_shutdown(); |
There was a problem hiding this comment.
Yeah it is very inconvenient that user need to manually call this
I think we should probably make it being called exactly once in BinderServerListener's ctor (by using static variable initialization)
grpc_init is probably too general for this. What if user don't meant to use any binder functionality? Their CPU will wast time initiating our stuff
WDYT
There was a problem hiding this comment.
Hmm. initializing the mutex and the object it protects at the same time is a bit tricky I think because mutex is not trivially destructible. IMHO putting them in grpc_init() and grpc_shutdown() (or functions they call) should be fine since it's just a few heap allocations at startup time. Probably need gRPC folks' opinion on whether this is acceptable and if so, where these functions should be called.
There was a problem hiding this comment.
@ctiller @markdroth We'd like to have your opinions on whether these should be called in grpc_init() / grpc_shutdown() as well. Thanks!
There was a problem hiding this comment.
@veblush what's holding up using absl::Mutex everywhere (which can be initialized statically?)
src/core/ext/transport/binder/server/binder_server_credentials.h
Outdated
Show resolved
Hide resolved
src/core/ext/transport/binder/server/binder_server_credentials.h
Outdated
Show resolved
Hide resolved
|
Moved @ctiller and @markdroth can you take a look at the design here? Currently we're using Thanks! |
|
TaWei: Any idea why |
I guess we were not building any Android code before in the CI since it's not included in tests, nor is it a target in
|
|
Ok then I think we should also check for binder API availability in the guard. Our code simply won't work with old version of NDK and API level. I will do that |
include/grpc/grpc.h
Outdated
| * binder transactions. | ||
| * Returns 1 on success, 0 on failure (or called in non-Android environments) | ||
| * REQUIRES: server not started */ | ||
| GRPCAPI int grpc_server_add_binder_port(grpc_server* server, const char* addr); |
There was a problem hiding this comment.
Public API additions will need a gRFC written.
There was a problem hiding this comment.
I wonder if we still need this C API for us to wrap C++ API around it. According to https://github.com/grpc/grpc/projects/8 it seems no longer relevant.
There was a problem hiding this comment.
Whilst I think it's probably a worthwhile idea, I don't think it's an actual official stance for the project (and if it were I think a gRFC would be needed for that).
We need a C API, and we need a gRFC for it.
There was a problem hiding this comment.
Sure, we will include this C API into our gRFC.
| /// Calling \a ServerBuilder::AddListeningPort() with Binder ServerCredentials | ||
| /// in a non-Android environment will make the subsequent call to | ||
| /// \a ServerBuilder::BuildAndStart() returns a null pointer. | ||
| std::shared_ptr<ServerCredentials> BinderServerCredentials(); |
There was a problem hiding this comment.
We decided to temporarily move the APIs back to internal headers because we need this PR in the internal testings and the RFC process is likely to take longer than desired. We're drafting a gRFC, and will make the APIs public once the RFC is approved. Thanks!
| }; | ||
|
|
||
| template <typename BinderTxReceiver> | ||
| int AddBinderPort(const std::string& addr, grpc_server* server) { |
| std::unique_ptr<grpc_binder::TransactionReceiver> tx_receiver_; | ||
| }; | ||
|
|
||
| template <typename BinderTxReceiver> |
There was a problem hiding this comment.
Make this template argument an interface instead.
There was a problem hiding this comment.
I've made it into a lambda that constructs the receiver.
8ffd3d6 to
8569feb
Compare
|
Public APIs has been removed. We will post a gRFC today or tomorrow. Craig: We would like to merge this first to unblock our implementation of CI testing (both public and internal), and adjust/extend our interface during the RFC review. WDYT? |
8569feb to
5cc724d
Compare
Also, make endpoint binder pool a gRPC core API so that it makes more sense to init/shutdown it in grpc_init() and grpc_shutdown(). However, grpc_endpoint_binder_pool_init() and grpc_endpoint_binder_pool_shutdown() are still called manually since it seems like grpc_init() only calls functions defined in src/core/lib.
* Make public APIs visible but function-less in non-Androind environments.
5cc724d to
6c6b3dc
Compare
Add `grpc::BinderServerCredentials()` and other related functionalities for the server to listen to binder transactions through a phony "binder port". The APIs are temporarily placed in internal headers until the corresponding gRFC is merged.
In order for the server to listen for binder connections, the users should tell the server to listen on a "binder port" using the binder server credentials. A "binder port" is represented as "binder://" followed by the service name, for example,
the server will now listen for binder connections to service "echo.service". The service name can be an arbitrary string and is used to retrieve the endpoint binder as follows
The Java service can then pass this endpoint binder to clients.
Depends on #26970.
@ctiller
@sifmelcara