pub struct FrameService { /* private fields */ }Expand description
A Tower Service that sends and receives raw RESP frames.
This is the lowest-level service primitive. It sends a Frame on the
wire and returns the response Frame. No command parsing, no type
safety – just raw frame I/O.
Use this as the inner service for Frame-level middleware (caching,
logging, metrics), then wrap with CommandAdapter to restore
typed command dispatch.
Cancelling an in-flight call closes the connection. Once a request may
have reached Redis, reusing its transport could let the next call consume
the cancelled request’s late response. A subsequent poll_ready therefore
returns RedisError::ConnectionClosed.
§Example
use futures::future::poll_fn;
use redis_tower_core::FrameService;
use redis_tower_protocol::helpers::{array, bulk};
use tower_service::Service;
let mut svc = FrameService::connect("127.0.0.1:6379").await?;
poll_fn(|cx| svc.poll_ready(cx)).await?;
let response = svc.call(array(vec![bulk("PING")])).await?;Implementations§
Source§impl FrameService
impl FrameService
Sourcepub async fn connect(addr: &str) -> Result<FrameService, RedisError>
pub async fn connect(addr: &str) -> Result<FrameService, RedisError>
Connect to a Redis server and create a FrameService.
Sourcepub fn from_connection(
conn: RedisConnection,
) -> Result<FrameService, RedisError>
pub fn from_connection( conn: RedisConnection, ) -> Result<FrameService, RedisError>
Create from an existing RedisConnection, consuming it.
Sourcepub fn subscribe_pushes(&mut self) -> UnboundedReceiver<Frame>
pub fn subscribe_pushes(&mut self) -> UnboundedReceiver<Frame>
Subscribe to RESP3 push messages.
Returns a receiver for out-of-band push frames (e.g., invalidation messages from CLIENT TRACKING). Push frames received during normal command execution are automatically routed to this channel.
Trait Implementations§
Source§impl ReleaseReadiness for FrameService
impl ReleaseReadiness for FrameService
Source§fn release_readiness(&mut self)
fn release_readiness(&mut self)
poll_ready when
no corresponding inner call will be made.Source§impl Service<Frame> for FrameService
impl Service<Frame> for FrameService
Source§type Error = RedisError
type Error = RedisError
Source§type Future = Pin<Box<dyn Future<Output = Result<Frame, RedisError>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<Frame, RedisError>> + Send>>
Auto Trait Implementations§
impl !Freeze for FrameService
impl !RefUnwindSafe for FrameService
impl !UnwindSafe for FrameService
impl Send for FrameService
impl Sync for FrameService
impl Unpin for FrameService
impl UnsafeUnpin for FrameService
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T, Request> ServiceExt<Request> for T
impl<T, Request> ServiceExt<Request> for T
Source§fn ready(&mut self) -> Ready<'_, Self, Request> ⓘwhere
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request> ⓘwhere
Self: Sized,
Source§fn ready_oneshot(self) -> ReadyOneshot<Self, Request> ⓘwhere
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request> ⓘwhere
Self: Sized,
Source§fn oneshot(self, req: Request) -> Oneshot<Self, Request> ⓘwhere
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request> ⓘwhere
Self: Sized,
Service, calling it with the provided request once it is ready.Source§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
poll_ready method. Read moreSource§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
poll_ready method. Read moreSource§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
poll_ready method. Read moreSource§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
Result<Self::Response, Self::Error>)
to a different value, regardless of whether the future succeeds or
fails. Read more