Skip to content
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

feat: display throughput for read session #25

Merged
merged 3 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
95 changes: 49 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pin-project-lite = "0.2"
pin-utils = "0.1.0"
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.132"
streamstore = { git = "https://github.com/s2-streamstore/s2-sdk-rust.git", rev = "54e36154a1aaf9ead2512bb446677cb7e94a4dc2" }
streamstore = { git = "https://github.com/s2-streamstore/s2-sdk-rust.git", rev = "ead36a9bf8177dab744ac158b625ffec9ea6c50a" }
thiserror = "1.0.67"
tokio = { version = "*", features = ["full"] }
tokio-stream = { version = "0.1.16", features = ["io-util"] }
Expand Down
42 changes: 25 additions & 17 deletions src/account.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use streamstore::{
client::Client,
service_error::{
CreateBasinError, DeleteBasinError, GetBasinConfigError, ReconfigureBasinError,
ServiceError,
},
types::{
BasinConfig, BasinMetadata, CreateBasinRequest, DeleteBasinRequest, ListBasinsRequest,
ListBasinsResponse, ReconfigureBasinRequest, StreamConfig,
},
};

use crate::error::s2_status;

pub struct AccountService {
client: Client,
}
Expand All @@ -19,17 +17,17 @@ pub enum AccountServiceError {
#[error("Failed to list basins: {0}")]
ListBasins(String),

#[error("Failed to create basin")]
CreateBasin(#[from] ServiceError<CreateBasinError>),
#[error("Failed to create basin: {0}")]
CreateBasin(String),

#[error("Failed to delete basin")]
DeleteBasin(#[from] ServiceError<DeleteBasinError>),
#[error("Failed to delete basin: {0}")]
DeleteBasin(String),

#[error("Failed to get basin config")]
GetBasinConfig(#[from] ServiceError<GetBasinConfigError>),
#[error("Failed to get basin config: {0}")]
GetBasinConfig(String),

#[error("Failed to reconfigure basin")]
ReconfigureBasin(#[from] ServiceError<ReconfigureBasinError>),
#[error("Failed to reconfigure basin: {0}")]
ReconfigureBasin(String),
}

impl AccountService {
Expand All @@ -51,7 +49,7 @@ impl AccountService {
self.client
.list_basins(list_basins_req)
.await
.map_err(|e| AccountServiceError::ListBasins(e.to_string()))
.map_err(|e| AccountServiceError::ListBasins(s2_status(&e)))
}

pub async fn create_basin(
Expand All @@ -76,20 +74,27 @@ impl AccountService {
self.client
.create_basin(create_basin_req)
.await
.map_err(AccountServiceError::CreateBasin)
.map_err(|e| AccountServiceError::CreateBasin(s2_status(&e)))
}

pub async fn delete_basin(&self, basin: String) -> Result<(), AccountServiceError> {
let delete_basin_req = DeleteBasinRequest::new(basin);
self.client.delete_basin(delete_basin_req).await?;
self.client
.delete_basin(delete_basin_req)
.await
.map_err(|e| AccountServiceError::DeleteBasin(s2_status(&e)))?;
Ok(())
}

pub async fn get_basin_config(
&self,
basin: String,
) -> Result<BasinConfig, AccountServiceError> {
Ok(self.client.get_basin_config(basin).await?)
Ok(self
.client
.get_basin_config(basin)
.await
.map_err(|e| AccountServiceError::GetBasinConfig(s2_status(&e)))?)
}

pub async fn reconfigure_basin(
Expand All @@ -101,7 +106,10 @@ impl AccountService {
let reconfigure_basin_req = ReconfigureBasinRequest::new(basin)
.with_config(basin_config)
.with_mask(mask);
self.client.reconfigure_basin(reconfigure_basin_req).await?;
self.client
.reconfigure_basin(reconfigure_basin_req)
.await
.map_err(|e| AccountServiceError::ReconfigureBasin(s2_status(&e)))?;
Ok(())
}
}
Loading