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

chore: Switch on missing_docs #106

Merged
merged 3 commits into from
Dec 12, 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
2 changes: 2 additions & 0 deletions src/batching.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Append records batching stream.

use std::{
pin::Pin,
task::{Context, Poll},
Expand Down
31 changes: 26 additions & 5 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! SDK client implementation.

use std::{env::VarError, fmt::Display, str::FromStr, time::Duration};

use backon::{BackoffBuilder, ConstantBuilder, Retryable};
Expand Down Expand Up @@ -97,6 +99,7 @@ pub struct S2Endpoints {
pub basin: BasinEndpoint,
}

/// Retry policy for append requests.
#[derive(Debug, Clone)]
pub enum AppendRetryPolicy {
/// Retry all eligible failures encountered during an append.
Expand All @@ -112,6 +115,7 @@ pub enum AppendRetryPolicy {
}

impl S2Endpoints {
/// Create S2 endpoints for the specified cloud.
pub fn for_cloud(cloud: S2Cloud) -> Self {
Self {
account: format!("{cloud}.s2.dev")
Expand All @@ -125,6 +129,7 @@ impl S2Endpoints {
}
}

/// Create S2 endpoints for the specified cell.
pub fn for_cell(
cloud: S2Cloud,
cell_id: impl Into<String>,
Expand All @@ -136,6 +141,13 @@ impl S2Endpoints {
})
}

/// Create S2 endpoints from environment variables.
///
/// The following environment variables are used:
/// - `S2_CLOUD`: Valid S2 cloud name. Defaults to AWS.
/// - `S2_ACCOUNT_ENDPOINT`: Overrides the account endpoint.
/// - `S2_BASIN_ENDPOINT`: Overrides the basin endpoint. The prefix `"{basin}."` indicates the
/// basin endpoint is `ParentZone` else `Direct`.
pub fn from_env() -> Result<Self, String> {
let cloud: S2Cloud = std::env::var("S2_CLOUD")
.ok()
Expand Down Expand Up @@ -244,11 +256,8 @@ impl ClientConfig {
}

/// User agent. Defaults to `s2-sdk-rust`. Feel free to say hi.
pub fn with_user_agent(self, user_agent: impl Into<HeaderValue>) -> Self {
Self {
user_agent: user_agent.into(),
..self
}
pub fn with_user_agent(self, user_agent: HeaderValue) -> Self {
Self { user_agent, ..self }
}

/// Retry policy for appends.
Expand Down Expand Up @@ -311,10 +320,15 @@ impl ClientConfig {
}
}

/// Error from client operations.
#[derive(Debug, Clone, thiserror::Error)]
pub enum ClientError {
/// SDK type conversion errors.
///
/// Indicates an incompatibility between the SDK version and service.
#[error(transparent)]
Conversion(#[from] types::ConvertError),
/// Error status from service.
#[error(transparent)]
Service(#[from] tonic::Status),
}
Expand All @@ -326,12 +340,14 @@ pub struct Client {
}

impl Client {
/// Create a new SDK client.
pub fn new(config: ClientConfig) -> Self {
Self {
inner: ClientInner::new(ClientKind::Account, config, DEFAULT_CONNECTOR),
}
}

/// Create a new SDK client using a custom connector.
#[cfg(feature = "connector")]
pub fn new_with_connector<C>(config: ClientConfig, connector: C) -> Self
where
Expand All @@ -345,6 +361,7 @@ impl Client {
}
}

/// Create basin client from the given name.
pub fn basin_client(&self, basin: types::BasinName) -> BasinClient {
BasinClient {
inner: self.inner.for_basin(basin),
Expand Down Expand Up @@ -421,12 +438,14 @@ pub struct BasinClient {
}

impl BasinClient {
/// Create a new basin client.
pub fn new(config: ClientConfig, basin: types::BasinName) -> Self {
Self {
inner: ClientInner::new(ClientKind::Basin(basin), config, DEFAULT_CONNECTOR),
}
}

/// Create a new basin client using a custom connector.
#[cfg(feature = "connector")]
pub fn new_with_connector<C>(
config: ClientConfig,
Expand Down Expand Up @@ -520,10 +539,12 @@ pub struct StreamClient {
}

impl StreamClient {
/// Create a new stream client.
pub fn new(config: ClientConfig, basin: types::BasinName, stream: impl Into<String>) -> Self {
BasinClient::new(config, basin).stream_client(stream)
}

/// Create a new stream client using a custom connector.
#[cfg(feature = "connector")]
pub fn new_with_connector<C>(
config: ClientConfig,
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! Rust SDK for S2.

#![warn(missing_docs)]

#[rustfmt::skip]
mod api;

Expand All @@ -8,5 +12,4 @@ pub mod batching;
pub mod client;
pub mod types;

pub use http::{uri, HeaderValue};
pub use service::Streaming;
Loading
Loading