Skip to content
Draft
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
11 changes: 9 additions & 2 deletions crates/lib/src/qpu/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ pub struct ExecutionOptions {
#[doc = "The timeout to use for the request, defaults to 30 seconds. If set to `None`, then there is no timeout."]
#[builder(default = "Some(Duration::from_secs(30))")]
timeout: Option<Duration>,
#[doc = "The timeout to use for the connection, defaults to `None`seconds. If set to `None`, then there is no timeout."]
#[builder(default = "Some(Duration::from_secs(30))")]
connection_timeout: Option<Duration>,
#[doc = "Options avaialable when executing a job on a QPU, particular to the execution service's API."]
#[builder(default = "None")]
api_options: Option<InnerApiExecutionOptions>,
Expand Down Expand Up @@ -278,7 +281,11 @@ impl ExecutionOptions {
pub fn timeout(&self) -> Option<Duration> {
self.timeout
}

/// Get the connection timeout.
#[must_use]
pub fn connection_timeout(&self) -> Option<Duration> {
self.connection_timeout
}
/// Get the [`ApiExecutionOptions`].
#[must_use]
pub fn api_options(&self) -> Option<&InnerApiExecutionOptions> {
Expand Down Expand Up @@ -381,7 +388,7 @@ impl ExecutionOptions {
client: &Qcs,
) -> Result<GrpcConnection, QpuApiError> {
let uri = parse_uri(address).map_err(QpuApiError::GrpcError)?;
let channel = get_channel_with_timeout(uri, self.timeout())
let channel = get_channel_with_timeout(uri, self.timeout(), self.connection_timeout())
.map_err(|err| QpuApiError::GrpcError(err.into()))?;
Ok(wrap_channel_with(channel, client.get_config().clone()))
}
Expand Down