pub struct RetryClient { /* private fields */ }Expand description
Retry client that wraps the base client with retry functionality
Implementations§
Source§impl RetryClient
impl RetryClient
Sourcepub fn new(
base_url: impl Into<String>,
max_retries: usize,
retry_delay: Duration,
) -> Self
pub fn new( base_url: impl Into<String>, max_retries: usize, retry_delay: Duration, ) -> Self
Creates a new retry client
§Arguments
base_url- The base URL of the scheduler servermax_retries- Maximum number of retry attemptsretry_delay- Delay between retry attempts
§Example
use go_server_rust_sdk::scheduler::RetryClient;
use std::time::Duration;
let client = RetryClient::new(
"http://localhost:8080",
3,
Duration::from_secs(1)
);Sourcepub async fn execute_with_retry(
&self,
method: impl Into<String> + Clone,
params: Value,
) -> Result<ResultResponse>
pub async fn execute_with_retry( &self, method: impl Into<String> + Clone, params: Value, ) -> Result<ResultResponse>
Executes a task with retry logic
This method will retry the execution up to max_retries times
if the request fails.
§Arguments
method- The method name to executeparams- The parameters for the method
§Returns
A ResultResponse containing the task ID and initial status
§Example
use go_server_rust_sdk::scheduler::RetryClient;
use serde_json::json;
use std::time::Duration;
let client = RetryClient::new(
"http://localhost:8080",
3,
Duration::from_secs(1)
);
let params = json!({"a": 10, "b": 20});
let response = client.execute_with_retry("add", params).await?;
println!("Task ID: {}", response.task_id);Sourcepub async fn execute_encrypted_with_retry(
&self,
method: impl Into<String> + Clone,
key: &str,
salt: i32,
params: Value,
) -> Result<ResultResponse>
pub async fn execute_encrypted_with_retry( &self, method: impl Into<String> + Clone, key: &str, salt: i32, params: Value, ) -> Result<ResultResponse>
Executes an encrypted task with retry logic
This method will retry the execution up to max_retries times
if the request fails.
§Arguments
method- The method name to executekey- The encryption keysalt- The salt value for key encryptionparams- The parameters for the method
§Returns
A ResultResponse containing the task ID and initial status
§Example
use go_server_rust_sdk::scheduler::RetryClient;
use serde_json::json;
use std::time::Duration;
let client = RetryClient::new(
"http://localhost:8080",
3,
Duration::from_secs(1)
);
let params = json!({"a": 10, "b": 20});
let response = client.execute_encrypted_with_retry(
"add",
"my-secret-key",
123456,
params
).await?;
println!("Task ID: {}", response.task_id);Sourcepub async fn execute_sync_with_retry(
&self,
method: impl Into<String> + Clone,
params: Value,
_timeout_duration: Duration,
) -> Result<ResultResponse>
pub async fn execute_sync_with_retry( &self, method: impl Into<String> + Clone, params: Value, _timeout_duration: Duration, ) -> Result<ResultResponse>
Executes a task synchronously with retry logic and timeout
This is a convenience method that combines retry logic with synchronous execution.
§Arguments
method- The method name to executeparams- The parameters for the methodtimeout_duration- Maximum time to wait for completion
§Returns
A ResultResponse containing the final task result
§Example
use go_server_rust_sdk::scheduler::RetryClient;
use serde_json::json;
use std::time::Duration;
let client = RetryClient::new(
"http://localhost:8080",
3,
Duration::from_secs(1)
);
let params = json!({"a": 10, "b": 20});
let result = client.execute_sync_with_retry(
"add",
params,
Duration::from_secs(30)
).await?;
println!("Result: {:?}", result.result);Sourcepub async fn execute_sync_encrypted_with_retry(
&self,
method: impl Into<String> + Clone,
key: &str,
salt: i32,
params: Value,
_timeout_duration: Duration,
) -> Result<ResultResponse>
pub async fn execute_sync_encrypted_with_retry( &self, method: impl Into<String> + Clone, key: &str, salt: i32, params: Value, _timeout_duration: Duration, ) -> Result<ResultResponse>
Executes an encrypted task synchronously with retry logic, decryption and timeout
This is a convenience method that combines retry logic with synchronous encrypted execution.
§Arguments
method- The method name to executekey- The encryption keysalt- The salt value for key encryptionparams- The parameters for the methodtimeout_duration- Maximum time to wait for completion
§Returns
A ResultResponse containing the decrypted task result
§Example
use go_server_rust_sdk::scheduler::RetryClient;
use serde_json::json;
use std::time::Duration;
let client = RetryClient::new(
"http://localhost:8080",
3,
Duration::from_secs(1)
);
let params = json!({"a": 10, "b": 20});
let result = client.execute_sync_encrypted_with_retry(
"add",
"my-secret-key",
123456,
params,
Duration::from_secs(30)
).await?;
println!("Decrypted result: {:?}", result.result);Trait Implementations§
Source§impl Clone for RetryClient
impl Clone for RetryClient
Source§fn clone(&self) -> RetryClient
fn clone(&self) -> RetryClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more