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 methods to builder for changing timeouts #498

Merged
Merged
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
21 changes: 21 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,27 @@ impl OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>
self
}

/// Set the connect timeout.
#[cfg(feature = "timeout")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really need its own feature flag? I think it's probably better to just have it included by default.

Copy link
Contributor Author

@johnrichardrinehart johnrichardrinehart Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. But, much of the timeout functionality is already guarded behind the timeout feature flag. I figured it'd be good to keep it in order to keep things consistent and to clean up the compiled output.

Note that I don't know what value it would provide users. If this code isn't guarded behind the timeout flag since then users who are not using the timeout flag will see methods that won't be of any use to them.

pub fn set_connect_timeout(mut self, timeout: Option<Duration>) -> Self {
self.config.connect_timeout = timeout;
self
}

/// Set the read timeout.
#[cfg(feature = "timeout")]
pub fn set_read_timeout(mut self, timeout: Option<Duration>) -> Self {
self.config.read_timeout = timeout;
self
}

/// Set the write timeout.
#[cfg(feature = "timeout")]
pub fn set_write_timeout(mut self, timeout: Option<Duration>) -> Self {
self.config.write_timeout = timeout;
self
}

/// Enable a GitHub preview.
pub fn add_preview(mut self, preview: &'static str) -> Self {
self.config.previews.push(preview);
Expand Down