Skip to content

Commit

Permalink
endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
shikhar committed Nov 20, 2024
1 parent a9897ff commit 1cc1c71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use streamstore::{
async fn main() {
let token = std::env::var("S2_AUTH_TOKEN").unwrap();

let host_endpoints = S2Endpoints::from_env().unwrap();
let endpoints = S2Endpoints::from_env().unwrap();

let config = ClientConfig::new(token)
.with_endpoints(host_endpoints)
.with_endpoints(endpoints)
.with_request_timeout(Duration::from_secs(10));

println!("Connecting with {config:#?}");
Expand Down
12 changes: 6 additions & 6 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl S2Endpoints {
#[derive(Debug, Clone)]
pub struct ClientConfig {
pub(crate) token: SecretString,
pub(crate) host_endpoints: S2Endpoints,
pub(crate) endpoints: S2Endpoints,
pub(crate) connection_timeout: Duration,
pub(crate) request_timeout: Duration,
pub(crate) user_agent: HeaderValue,
Expand All @@ -263,7 +263,7 @@ impl ClientConfig {
pub fn new(token: impl Into<String>) -> Self {
Self {
token: token.into().into(),
host_endpoints: S2Endpoints::default(),
endpoints: S2Endpoints::default(),
connection_timeout: Duration::from_secs(3),
request_timeout: Duration::from_secs(5),
user_agent: "s2-sdk-rust".parse().expect("valid user agent"),
Expand All @@ -277,7 +277,7 @@ impl ClientConfig {
/// S2 endpoints to connect to.
pub fn with_endpoints(self, host_endpoints: impl Into<S2Endpoints>) -> Self {
Self {
host_endpoints: host_endpoints.into(),
endpoints: host_endpoints.into(),
..self
}
}
Expand Down Expand Up @@ -650,12 +650,12 @@ impl ClientInner {
C::Future: Send,
C::Error: std::error::Error + Send + Sync + 'static,
{
let cell_endpoint = config.host_endpoints.cell.clone();
let cell_endpoint = config.endpoints.cell.clone();
Self::new(config, cell_endpoint, connector)
}

fn new_basin(&self, basin: types::BasinName) -> Self {
match self.config.host_endpoints.basin_zone.clone() {
match self.config.endpoints.basin_zone.clone() {
Some(endpoint) => {
let basin_endpoint: Authority = format!("{basin}.{endpoint}")
.parse()
Expand Down Expand Up @@ -698,7 +698,7 @@ impl ClientInner {

let channel = if let Some(connector) = connector {
assert!(
config.host_endpoints.basin_zone.is_none(),
config.endpoints.basin_zone.is_none(),
"cannot connect with connector if basin zone is provided"
);
endpoint.connect_with_connector_lazy(connector)
Expand Down

0 comments on commit 1cc1c71

Please sign in to comment.