Skip to main content

SynapConfig

Struct SynapConfig 

Source
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: String

Base URL of the Synap HTTP server (used for HTTP transport and fallback).

§rpc_host: String

Host for the SynapRPC TCP listener (default: 127.0.0.1).

§rpc_port: u16

Port for the SynapRPC TCP listener (default: 15501).

§resp3_host: String

Host for the RESP3 TCP listener (default: 127.0.0.1).

§resp3_port: u16

Port for the RESP3 TCP listener (default: 6379).

§transport: TransportMode

Which binary protocol to use as primary transport (default: SynapRpc).

§timeout: Duration

Request / connection timeout.

§max_retries: u32

Maximum 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

Source

pub fn new(url: impl Into<String>) -> Self

Create a configuration, inferring the transport from the URL scheme.

SchemeTransportDefault 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");
Source

pub fn with_http_transport(self) -> Self

👎Deprecated since 0.11.0:

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.

Source

pub fn with_synap_rpc_transport(self) -> Self

👎Deprecated since 0.11.0:

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.

Source

pub fn with_resp3_transport(self) -> Self

👎Deprecated since 0.11.0:

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.

Source

pub 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

Override the SynapRPC listener address (host + port).

§Deprecated

Encode the host and port in the synap://host:port URL instead.

Source

pub 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

Override the RESP3 listener address (host + port).

§Deprecated

Encode the host and port in the resp3://host:port URL instead.

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Set the timeout for connections and requests.

Source

pub fn with_auth_token(self, token: impl Into<String>) -> Self

Set the authentication token (API key / Bearer token for HTTP).

Source

pub fn with_basic_auth( self, username: impl Into<String>, password: impl Into<String>, ) -> Self

Set HTTP Basic Auth credentials.

Source

pub fn with_max_retries(self, max_retries: u32) -> Self

Set the maximum HTTP retry attempts.

Trait Implementations§

Source§

impl Clone for SynapConfig

Source§

fn clone(&self) -> SynapConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SynapConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more