-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(grpc): Add tonic transport #2339
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
base: master
Are you sure you want to change the base?
Conversation
1417e9d
to
66e6c10
Compare
Hi @dfawley and @LucioFranco, could you please review this PR when you have a moment? |
fe1436e
to
957377c
Compare
@@ -229,6 +235,7 @@ impl InternalSubchannel { | |||
transport: Arc<dyn Transport>, | |||
backoff: Arc<dyn Backoff>, | |||
unregister_fn: Box<dyn FnOnce(SubchannelKey) + Send + Sync>, | |||
runtime: Arc<dyn Runtime>, |
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.
Curious:
Given that we will have the same runtime for all the different gRPC components that require a runtime, did we consider something like a singleton that is initialized at init time, and all the components can use a getter to retrieve and use the singleton instead of the runtime being passed to every component that needs it?
@@ -345,30 +353,34 @@ impl InternalSubchannel { | |||
let transport = self.transport.clone(); | |||
let address = self.address().address; | |||
let state_machine_tx = self.state_machine_event_sender.clone(); | |||
let connect_task = tokio::task::spawn(async move { |
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.
Do we have some kind of vet
equivalent to ensure that task spawning (and other features provided by the runtime) are always only used from the runtime and not from other places (like tokio or the standard library)?
self.m | ||
.lock() | ||
.unwrap() | ||
.insert(address_type.to_string(), Arc::new(transport)); | ||
} | ||
|
||
/// Retrieve a name resolver from the registry, or None if not found. |
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.
Nit: this comments needs updating.
@@ -26,20 +25,20 @@ impl std::fmt::Debug for TransportRegistry { | |||
|
|||
impl TransportRegistry { | |||
/// Construct an empty name resolver registry. | |||
pub fn new() -> Self { | |||
pub(crate) fn new() -> Self { |
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.
Should we also implement Default
trait for this type by inheriting it?
@@ -388,7 +400,9 @@ impl InternalSubchannel { | |||
// error string containing information about why the connection | |||
// terminated? But what can we do with that error other than logging | |||
// it, which the transport can do as well? | |||
svc.disconnected().await; | |||
if let Err(e) = closed_rx.await { |
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.
Should the above task spawn be on the runtime as well instead of directly using tokio
?
This PR includes the following:
tonic/src/transport
, required code is copied over.Bytes
. This is a temporary workaround until tonic supports bypassing the codec and receiving bytes.