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: Add option to set a request timeout #81

Merged
merged 4 commits into from
May 5, 2024
Merged
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ hyper-rustls = { version = "0.26.0", default-features = false, features = ["http
rustls-pemfile = "2.1.1"
rustls = "0.22.4"
parking_lot = "0.12"
tokio = { version = "1", features = ["time"] }

[dev-dependencies]
argparse = "0.2"
Expand Down
6 changes: 5 additions & 1 deletion examples/certificate_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
};

let mut certificate = std::fs::File::open(certificate_file)?;
Ok(Client::certificate(&mut certificate, &password, endpoint)?)

// Create config with the given endpoint and default timeouts
let client_config = a2::ClientConfig::new(endpoint);

Ok(Client::certificate(&mut certificate, &password, client_config)?)
}
#[cfg(all(not(feature = "openssl"), feature = "ring"))]
{
Expand Down
9 changes: 7 additions & 2 deletions examples/token_client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use argparse::{ArgumentParser, Store, StoreOption, StoreTrue};
use std::fs::File;

use a2::{Client, DefaultNotificationBuilder, Endpoint, NotificationBuilder, NotificationOptions};
use a2::{
client::ClientConfig, Client, DefaultNotificationBuilder, Endpoint, NotificationBuilder, NotificationOptions,
};

// An example client connectiong to APNs with a JWT token
#[tokio::main]
Expand Down Expand Up @@ -46,8 +48,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
Endpoint::Production
};

// Create config with the given endpoint and default timeouts
let client_config = ClientConfig::new(endpoint);

// Connecting to APNs
let client = Client::token(&mut private_key, key_id, team_id, endpoint).unwrap();
let client = Client::token(&mut private_key, key_id, team_id, client_config).unwrap();

let options = NotificationOptions {
apns_topic: topic.as_deref(),
Expand Down
Loading
Loading