pub struct PulseClient { /* private fields */ }Expand description
Async HTTP client for the Pulse REST API.
§Example
use pulse_client::PulseClient;
let client = PulseClient::builder()
.base_url("http://localhost:9090")
.build()?;
client.auth().login("alice", "secret").await?;
for pipeline in client.pipelines().list().await? {
println!("{}", pipeline["name"]);
}§Thread safety
PulseClient is Clone and cheap to clone — the underlying reqwest client
pools connections, and the token sits behind an Arc<RwLock>. Share a
single instance across tasks.
Implementations§
Source§impl PulseClient
impl PulseClient
pub fn builder() -> PulseClientBuilder
Sourcepub fn token(&self) -> Option<String>
pub fn token(&self) -> Option<String>
Returns the current bearer token, or None if none is set.
Sourcepub fn set_token<S: Into<String>>(&self, token: S)
pub fn set_token<S: Into<String>>(&self, token: S)
Updates the bearer token used by subsequent authenticated requests. Safe to call from multiple tasks concurrently.
Sourcepub fn clear_token(&self)
pub fn clear_token(&self)
Clears the bearer token, effectively logging out the client.
pub fn auth(&self) -> AuthResource<'_>
pub fn pipelines(&self) -> PipelinesResource<'_>
pub fn agents(&self) -> AgentsResource<'_>
pub fn templates(&self) -> TemplatesResource<'_>
pub fn users(&self) -> UsersResource<'_>
Sourcepub fn models(&self) -> ModelsResource<'_>
pub fn models(&self) -> ModelsResource<'_>
client.models() — B-112 embedded ML model registry (upload / list /
get / delete ONNX models scored by the streaming ml_predict operator).
Sourcepub fn connectors(&self) -> ConnectorsResource<'_>
pub fn connectors(&self) -> ConnectorsResource<'_>
client.connectors() — the connector catalogue (B-093 family + every
native / bridged connector); use a subType as a pipeline node type.
pub fn events(&self) -> EventsResource<'_>
pub fn iq(&self) -> IQResource<'_>
Sourcepub fn streams(&self) -> StreamsResource<'_>
pub fn streams(&self) -> StreamsResource<'_>
client.streams() — B-107 Kafka-Streams-like declarative DSL.
Sourcepub async fn duplex(&self, agent_id: &str) -> Result<DuplexChannel, PulseError>
pub async fn duplex(&self, agent_id: &str) -> Result<DuplexChannel, PulseError>
B-114 — open a bidirectional duplex channel to an agent.
Streams events IN and receives the agent’s correlated outputs OUT on a single WebSocket — the synchronous-decision path (fraud, pricing, A/B assignment). The endpoint runs on the Pulse WebSocket port (REST port
- 1); the URL is derived from this client’s
base_url+ token.
let mut ch = client.duplex("fraud-detector").await?;
let cid = ch.send(&json!({ "amount": 5000 }), Some("tx-1")).await?;
let output = ch.recv().await?;
assert_eq!(output.correlation_id, Some(cid));
ch.close().await?;§Errors
PulseError::InvalidConfigifagent_idis blank.PulseError::Duplexon a WebSocket handshake / transport failure.PulseError::Validationif the server rejects the agent with anerrorframe on open.
Sourcepub async fn duplex_at(
&self,
ws_url: impl Into<String>,
) -> Result<DuplexChannel, PulseError>
pub async fn duplex_at( &self, ws_url: impl Into<String>, ) -> Result<DuplexChannel, PulseError>
Open a duplex channel at an explicit WebSocket URL, bypassing the REST-port-+-1 derivation. Useful when the WebSocket endpoint sits behind a separate gateway / hostname.
Sourcepub async fn version(&self) -> Result<Value, PulseError>
pub async fn version(&self) -> Result<Value, PulseError>
GET /api/pulse/version — public, no JWT required. Returns the
Pulse server’s build + version metadata.
Trait Implementations§
Source§impl Clone for PulseClient
impl Clone for PulseClient
Source§fn clone(&self) -> PulseClient
fn clone(&self) -> PulseClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more