Skip to content

Commit

Permalink
feat(term): set timeout for the github client
Browse files Browse the repository at this point in the history
  • Loading branch information
ymgyt committed Aug 31, 2024
1 parent 35981ef commit 96e4762
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/synd_term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ humantime = { workspace = true }
itertools = { workspace = true }
nom = { version = "7.1.3", default-features = false, features = ["std"] }
nucleo = "0.5.0"
octocrab = { workspace = true }
octocrab = { workspace = true, features = ["timeout", "tracing"] }
open = "5.3.0"
ratatui = { version = "0.28.1" }
reqwest = { workspace = true }
Expand Down
5 changes: 4 additions & 1 deletion crates/synd_term/src/client/github/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ impl GithubClient {
pub fn new(pat: impl Into<String>) -> Self {
// TODO: configure timeout
let octo = Octocrab::builder()
.personal_token(pat.into())
.personal_token(pat)
.set_connect_timeout(timeout)
.set_read_timeout(timeout)
.set_write_timeout(timeout)
.build()
.unwrap();
Self::with(octo)
Expand Down
3 changes: 3 additions & 0 deletions crates/synd_term/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ pub mod cache {
}

pub(crate) mod github {
use std::time::Duration;

/// GitHub pagination rest api is 1 origin
pub(crate) const INITIAL_PAGE_NUM: u8 = 1;
pub(crate) const NOTIFICATION_PER_PAGE: u8 = 40;
pub(crate) const CLIENT_TIMEOUT: Duration = Duration::from_secs(30);
}

pub(crate) mod theme {
Expand Down

0 comments on commit 96e4762

Please sign in to comment.