Struct hitbox_actix::actor::CacheActor[][src]

pub struct CacheActor<B> where
    B: Backend
{ /* fields omitted */ }
Expand description

Actix actor implements cache logic.

This actor implement only Handler<QueryCache>. Where QueryCache - Actix message with two fields:

  • Generic actix message for sending to upstream actor.
  • Address of upstream actor

Example

use actix::prelude::*;
use hitbox_actix::{Cache, RedisBackend, CacheError};

#[actix_rt::main]
async fn main() -> Result<(), CacheError> {
    let cache = Cache::new().await?.start();
    Ok(())
}

Implementations

impl<B> CacheActor<B> where
    B: Actor + Backend,
    <B as Actor>::Context: ToEnvelope<B, Get> + ToEnvelope<B, Set> + ToEnvelope<B, Lock> + ToEnvelope<B, Delete>, 
[src]

pub async fn new() -> Result<CacheActor<RedisBackend>, CacheError>[src]

Initialize new Cache actor with default hitbox_redis::RedisBackend.

pub fn builder() -> CacheBuilder<B>[src]

Creates new CacheBuilder instance for Cache actor configuration.

Trait Implementations

impl<B> Actor for CacheActor<B> where
    B: Backend
[src]

type Context = Context<Self>

Actor execution context type

fn started(&mut self, _: &mut Self::Context)[src]

Called when an actor gets polled the first time.

fn stopping(&mut self, ctx: &mut Self::Context) -> Running[src]

Called after an actor is in Actor::Stopping state. Read more

fn stopped(&mut self, ctx: &mut Self::Context)[src]

Called after an actor is stopped. Read more

fn start(self) -> Addr<Self> where
    Self: Actor<Context = Context<Self>>, 
[src]

Start a new asynchronous actor, returning its address. Read more

fn start_default() -> Addr<Self> where
    Self: Actor<Context = Context<Self>> + Default
[src]

Construct and start a new asynchronous actor, returning its address. Read more

fn start_in_arbiter<F>(arb: &Arbiter, f: F) -> Addr<Self> where
    Self: Actor<Context = Context<Self>>,
    F: FnOnce(&mut Context<Self>) -> Self + Send + 'static, 
[src]

Start new actor in arbiter’s thread.

fn create<F>(f: F) -> Addr<Self> where
    Self: Actor<Context = Context<Self>>,
    F: FnOnce(&mut Context<Self>) -> Self, 
[src]

Start a new asynchronous actor given a Context. Read more

impl<'a, A, M, B> Handler<QueryCache<A, M>> for CacheActor<B> where
    B: Actor + Backend,
    <B as Actor>::Context: ToEnvelope<B, Get> + ToEnvelope<B, Set> + ToEnvelope<B, Lock> + ToEnvelope<B, Delete>,
    A: Actor + Handler<M> + Send,
    M: Message + Cacheable + Send + 'static,
    M::Result: MessageResponse<A, M> + CacheableResponse + Debug + Send,
    <<M as Message>::Result as CacheableResponse>::Cached: Serialize + DeserializeOwned,
    <A as Actor>::Context: ToEnvelope<A, M>, 
[src]

type Result = ResponseFuture<Result<<M as Message>::Result, CacheError>>

The type of value that this handler will return. Read more

fn handle(
    &mut self,
    msg: QueryCache<A, M>,
    _: &mut Self::Context
) -> Self::Result
[src]

This method is called for every message received by this actor.

Auto Trait Implementations

impl<B> !RefUnwindSafe for CacheActor<B>

impl<B> Send for CacheActor<B>

impl<B> Sync for CacheActor<B>

impl<B> Unpin for CacheActor<B>

impl<B> !UnwindSafe for CacheActor<B>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

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

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

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

pub fn vzip(self) -> V