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
2 changes: 1 addition & 1 deletion hypersync-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hypersync-client"
version = "0.20.0-rc.3"
version = "0.20.0-rc.5"
edition = "2021"
description = "client library for hypersync"
license = "MPL-2.0"
Expand Down
15 changes: 15 additions & 0 deletions hypersync-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,28 @@ pub struct Client {
impl Client {
/// Creates a new client with the given configuration.
pub fn new(cfg: ClientConfig) -> Result<Self> {
// hscr stands for hypersync client rust
let user_agent = format!("hscr/{}", env!("CARGO_PKG_VERSION"));
Self::new_internal(cfg, user_agent)
}

#[doc(hidden)]
pub fn new_with_agent(cfg: ClientConfig, user_agent: impl Into<String>) -> Result<Self> {
// Creates a new client with the given configuration and custom user agent.
// This is intended for use by language bindings (Python, Node.js) and HyperIndex.
Self::new_internal(cfg, user_agent.into())
}

/// Internal constructor that takes both config and user agent.
fn new_internal(cfg: ClientConfig, user_agent: String) -> Result<Self> {
let timeout = cfg
.http_req_timeout_millis
.unwrap_or(NonZeroU64::new(30_000).unwrap());

let http_client = reqwest::Client::builder()
.no_gzip()
.timeout(Duration::from_millis(timeout.get()))
.user_agent(user_agent)
.build()
.unwrap();

Expand Down
Loading