Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 24 additions & 21 deletions grpc/src/client/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
*
* Copyright 2025 gRPC authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/

Expand Down Expand Up @@ -65,8 +65,7 @@ use crate::client::name_resolution::Target;
use crate::client::name_resolution::dns;
use crate::client::name_resolution::global_registry;
use crate::client::name_resolution::{self};
use crate::client::service_config::LbPolicyType;
use crate::client::service_config::ServiceConfig;
use crate::client::service_config::ParseResult;
use crate::client::stream_util::FailingRecvStream;
use crate::client::subchannel::InternalSubchannel;
use crate::client::subchannel::NopBackoff;
Expand Down Expand Up @@ -250,8 +249,9 @@ struct PersistentChannel {
}

impl PersistentChannel {
/// Returns the current state of the channel. If there is no underlying active channel,
/// returns Idle. If `connect` is true, will create a new active channel iff none exists.
/// Returns the current state of the channel. If there is no underlying active
/// channel, returns Idle. If `connect` is true, will create a new active
/// channel iff none exists.
fn get_state(&self, connect: bool) -> ConnectivityState {
// Done this away to avoid potentially locking twice.
let active_channel = if connect {
Expand All @@ -268,8 +268,9 @@ impl PersistentChannel {
active_channel.lb_watcher.cur().connectivity_state
}

/// Gets the underlying active channel. If there is no current connection, it will create one.
/// This cannot fail and will always return a valid active channel.
/// Gets the underlying active channel. If there is no current connection,
/// it will create one. This cannot fail and will always return a valid
/// active channel.
fn get_active_channel(&self) -> Arc<ActiveChannel> {
let mut active_channel = self.active_channel.lock().unwrap();

Expand All @@ -283,8 +284,10 @@ impl PersistentChannel {

// A channel that is not idle (connecting, ready, or erroring).
struct ActiveChannel {
abort_handle: Box<dyn rt::TaskHandle>, // Work scheduler task killed when ActiveChannel is dropped.
lb_watcher: Arc<Watcher<LbState>>, // For getting the channel connectivity state and pickers for RPCs.
abort_handle: Box<dyn rt::TaskHandle>, /* Work scheduler task killed when ActiveChannel is
* dropped. */
lb_watcher: Arc<Watcher<LbState>>, /* For getting the channel connectivity state and pickers
* for RPCs. */
}

impl ActiveChannel {
Expand Down Expand Up @@ -448,9 +451,9 @@ impl name_resolution::ChannelController for ResolverChannelController {
fn update(&mut self, update: ResolverUpdate) -> Result<(), String> {
let json_config = if let Ok(Some(service_config)) = update.service_config.as_ref()
&& service_config
.load_balancing_policy
.load_balancing_config
.as_ref()
.is_some_and(|p| *p == LbPolicyType::RoundRobin)
.is_some_and(|lbc| lbc.iter().any(|c| c.name == "round_robin"))
{
json!([{round_robin::POLICY_NAME: {}}])
Comment thread
nathanielford marked this conversation as resolved.
} else {
Expand All @@ -466,7 +469,7 @@ impl name_resolution::ChannelController for ResolverChannelController {
.map_err(|err| err.to_string())
}

fn parse_service_config(&self, config: &str) -> Result<ServiceConfig, String> {
fn parse_service_config(&self, config: &str) -> ParseResult {
Err("service configs not supported".to_string())
}
}
Expand Down
23 changes: 12 additions & 11 deletions grpc/src/client/name_resolution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
*
* Copyright 2025 gRPC authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/

Expand All @@ -42,6 +42,7 @@ use url::Url;

use crate::attributes::Attributes;
use crate::byte_str::ByteStr;
use crate::client::service_config::ParseResult;
use crate::client::service_config::ServiceConfig;
use crate::rt::GrpcRuntime;

Expand Down Expand Up @@ -265,7 +266,7 @@ pub trait ChannelController: Send + Sync {

/// Parses the provided JSON service config and returns an instance of a
/// ParsedServiceConfig.
fn parse_service_config(&self, config: &str) -> Result<ServiceConfig, String>;
fn parse_service_config(&self, config: &str) -> ParseResult;
}

#[derive(Clone, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions grpc/src/client/name_resolution/proxy_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::client::name_resolution::ResolverOptions;
use crate::client::name_resolution::ResolverUpdate;
use crate::client::name_resolution::Target;
use crate::client::name_resolution::dns;
use crate::client::service_config::ServiceConfig;
use crate::client::service_config::ParseResult;
use crate::client::transport::ProxyOptions;
use crate::credentials::common::Authority;

Expand Down Expand Up @@ -227,7 +227,7 @@ impl<'a> ChannelController for InterceptingController<'a> {
self.inner.update(update)
}

fn parse_service_config(&self, config: &str) -> Result<ServiceConfig, String> {
fn parse_service_config(&self, config: &str) -> ParseResult {
self.inner.parse_service_config(config)
}
}
Expand Down
4 changes: 2 additions & 2 deletions grpc/src/client/name_resolution/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use tokio::sync::mpsc;
use crate::client::name_resolution::ChannelController;
use crate::client::name_resolution::ResolverUpdate;
use crate::client::name_resolution::WorkScheduler;
use crate::client::service_config::ServiceConfig;
use crate::client::service_config::ParseResult;

/// A work scheduler for testing.
pub(crate) struct TestWorkScheduler {
Expand Down Expand Up @@ -80,7 +80,7 @@ impl ChannelController for TestChannelController {
self.update_result.clone()
}

fn parse_service_config(&self, _: &str) -> Result<ServiceConfig, String> {
fn parse_service_config(&self, _: &str) -> ParseResult {
Err("Unimplemented".to_string())
}
}
38 changes: 0 additions & 38 deletions grpc/src/client/service_config.rs

This file was deleted.

Loading
Loading