pub struct SynapConfig {
pub base_url: String,
pub rpc_host: String,
pub rpc_port: u16,
pub resp3_host: String,
pub resp3_port: u16,
pub transport: TransportMode,
pub timeout: Duration,
pub max_retries: u32,
pub auth_token: Option<String>,
pub username: Option<String>,
pub password: Option<String>,
}Expand description
Synap client configuration.
Fields§
§base_url: StringBase URL of the Synap HTTP server (used for HTTP transport and fallback).
rpc_host: StringHost for the SynapRPC TCP listener (default: 127.0.0.1).
rpc_port: u16Port for the SynapRPC TCP listener (default: 15501).
resp3_host: StringHost for the RESP3 TCP listener (default: 127.0.0.1).
resp3_port: u16Port for the RESP3 TCP listener (default: 6379).
transport: TransportModeWhich binary protocol to use as primary transport (default: SynapRpc).
timeout: DurationRequest / connection timeout.
max_retries: u32Maximum retry attempts for HTTP requests.
auth_token: Option<String>Optional API key token (Bearer token for HTTP).
username: Option<String>Optional username for HTTP Basic Auth.
password: Option<String>Optional password for HTTP Basic Auth.
Implementations§
Source§impl SynapConfig
impl SynapConfig
Sourcepub fn new(url: impl Into<String>) -> Self
pub fn new(url: impl Into<String>) -> Self
Create a configuration, inferring the transport from the URL scheme.
| Scheme | Transport | Default port |
|---|---|---|
http:// or https:// | HTTP REST | — (as given) |
synap:// | SynapRPC (MessagePack/TCP) | 15501 |
resp3:// | RESP3 (Redis wire/TCP) | 6379 |
For synap:// and resp3:// URLs the host and port are parsed from
the URL. The HTTP base URL is set to http://<host>:15500 as a
convenience for any HTTP-only admin calls.
§Examples
use synap_sdk::SynapConfig;
let c = SynapConfig::new("synap://localhost:15501");
let c = SynapConfig::new("resp3://localhost:6379");
let c = SynapConfig::new("http://localhost:15500");Sourcepub fn with_http_transport(self) -> Self
👎Deprecated since 0.11.0: Pass an http:// URL to SynapConfig::new instead
pub fn with_http_transport(self) -> Self
Pass an http:// URL to SynapConfig::new instead
Use the HTTP REST transport only (original SDK behaviour).
§Deprecated
Prefer passing an http:// URL to SynapConfig::new.
Sourcepub fn with_synap_rpc_transport(self) -> Self
👎Deprecated since 0.11.0: Pass a synap:// URL to SynapConfig::new instead
pub fn with_synap_rpc_transport(self) -> Self
Pass a synap:// URL to SynapConfig::new instead
Use the SynapRPC binary transport (MessagePack over TCP). This is the default and has the lowest latency of the three options.
§Deprecated
Prefer passing a synap:// URL to SynapConfig::new.
Sourcepub fn with_resp3_transport(self) -> Self
👎Deprecated since 0.11.0: Pass a resp3:// URL to SynapConfig::new instead
pub fn with_resp3_transport(self) -> Self
Pass a resp3:// URL to SynapConfig::new instead
Use the RESP3 text transport (Redis-compatible wire protocol over TCP).
§Deprecated
Prefer passing a resp3:// URL to SynapConfig::new.
Sourcepub fn with_rpc_addr(self, host: impl Into<String>, port: u16) -> Self
👎Deprecated since 0.11.0: Encode host and port in the synap:// URL passed to SynapConfig::new
pub fn with_rpc_addr(self, host: impl Into<String>, port: u16) -> Self
Encode host and port in the synap:// URL passed to SynapConfig::new
Override the SynapRPC listener address (host + port).
§Deprecated
Encode the host and port in the synap://host:port URL instead.
Sourcepub fn with_resp3_addr(self, host: impl Into<String>, port: u16) -> Self
👎Deprecated since 0.11.0: Encode host and port in the resp3:// URL passed to SynapConfig::new
pub fn with_resp3_addr(self, host: impl Into<String>, port: u16) -> Self
Encode host and port in the resp3:// URL passed to SynapConfig::new
Override the RESP3 listener address (host + port).
§Deprecated
Encode the host and port in the resp3://host:port URL instead.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set the timeout for connections and requests.
Sourcepub fn with_auth_token(self, token: impl Into<String>) -> Self
pub fn with_auth_token(self, token: impl Into<String>) -> Self
Set the authentication token (API key / Bearer token for HTTP).
Sourcepub fn with_basic_auth(
self,
username: impl Into<String>,
password: impl Into<String>,
) -> Self
pub fn with_basic_auth( self, username: impl Into<String>, password: impl Into<String>, ) -> Self
Set HTTP Basic Auth credentials.
Sourcepub fn with_max_retries(self, max_retries: u32) -> Self
pub fn with_max_retries(self, max_retries: u32) -> Self
Set the maximum HTTP retry attempts.
Trait Implementations§
Source§impl Clone for SynapConfig
impl Clone for SynapConfig
Source§fn clone(&self) -> SynapConfig
fn clone(&self) -> SynapConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more