pub struct ClientConfig {
pub endpoint: String,
pub grpc_endpoint: Option<String>,
pub http_endpoint: Option<String>,
pub transport: TransportMode,
pub api_key: Option<String>,
pub token: Option<String>,
pub run_id: Option<String>,
pub timeout_ms: u64,
}Fields§
§endpoint: String§grpc_endpoint: Option<String>§http_endpoint: Option<String>§transport: TransportMode§api_key: Option<String>§token: Option<String>§run_id: Option<String>§timeout_ms: u64Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn new(endpoint: impl Into<String>) -> Self
pub fn new(endpoint: impl Into<String>) -> Self
Examples found in repository?
examples/support/utils.rs (line 73)
60pub async fn create_client() -> Result<Client, Box<dyn Error>> {
61 let endpoint =
62 env::var("MUBIT_ENDPOINT").unwrap_or_else(|_| "http://127.0.0.1:3000".to_string());
63 let grpc_endpoint =
64 env::var("MUBIT_GRPC_ENDPOINT").unwrap_or_else(|_| "127.0.0.1:50051".to_string());
65 let timeout_ms = env::var("MUBIT_TIMEOUT_MS")
66 .ok()
67 .and_then(|raw| raw.parse::<u64>().ok())
68 .unwrap_or(30_000);
69
70 let api_key =
71 env::var("MUBIT_API_KEY").map_err(|_| boxed_error("MUBIT_API_KEY must be set"))?;
72
73 let mut cfg = ClientConfig::new(endpoint).transport("http");
74 cfg.grpc_endpoint = Some(grpc_endpoint);
75 cfg.timeout_ms = timeout_ms;
76 cfg.api_key = Some(api_key.clone());
77
78 let client = Client::new(cfg)?;
79 client.set_transport(TransportMode::Http);
80 client.set_api_key(Some(api_key));
81
82 let _ = client.auth.health().await?;
83
84 Ok(client)
85}Sourcepub fn transport(self, transport: impl AsRef<str>) -> Self
pub fn transport(self, transport: impl AsRef<str>) -> Self
Examples found in repository?
examples/support/utils.rs (line 73)
60pub async fn create_client() -> Result<Client, Box<dyn Error>> {
61 let endpoint =
62 env::var("MUBIT_ENDPOINT").unwrap_or_else(|_| "http://127.0.0.1:3000".to_string());
63 let grpc_endpoint =
64 env::var("MUBIT_GRPC_ENDPOINT").unwrap_or_else(|_| "127.0.0.1:50051".to_string());
65 let timeout_ms = env::var("MUBIT_TIMEOUT_MS")
66 .ok()
67 .and_then(|raw| raw.parse::<u64>().ok())
68 .unwrap_or(30_000);
69
70 let api_key =
71 env::var("MUBIT_API_KEY").map_err(|_| boxed_error("MUBIT_API_KEY must be set"))?;
72
73 let mut cfg = ClientConfig::new(endpoint).transport("http");
74 cfg.grpc_endpoint = Some(grpc_endpoint);
75 cfg.timeout_ms = timeout_ms;
76 cfg.api_key = Some(api_key.clone());
77
78 let client = Client::new(cfg)?;
79 client.set_transport(TransportMode::Http);
80 client.set_api_key(Some(api_key));
81
82 let _ = client.auth.health().await?;
83
84 Ok(client)
85}pub fn api_key(self, api_key: impl Into<String>) -> Self
pub fn token(self, token: impl Into<String>) -> Self
pub fn run_id(self, run_id: impl Into<String>) -> Self
pub fn from_env() -> Self
Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§fn clone(&self) -> ClientConfig
fn clone(&self) -> ClientConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ClientConfig
impl Debug for ClientConfig
Auto Trait Implementations§
impl Freeze for ClientConfig
impl RefUnwindSafe for ClientConfig
impl Send for ClientConfig
impl Sync for ClientConfig
impl Unpin for ClientConfig
impl UnsafeUnpin for ClientConfig
impl UnwindSafe for ClientConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request