mirror of
https://github.com/actix/actix-extras.git
synced 2024-12-01 02:44:37 +01:00
Merge branch 'master' of github.com:actix/actix-redis
This commit is contained in:
commit
c6fc09ada8
11
src/lib.rs
11
src/lib.rs
@ -1,3 +1,12 @@
|
|||||||
|
//! Redis integration for Actix framework.
|
||||||
|
//!
|
||||||
|
//! ## Documentation
|
||||||
|
//! * [API Documentation (Development)](http://actix.github.io/actix-redis/actix_redis/)
|
||||||
|
//! * [API Documentation (Releases)](https://docs.rs/actix-redis/)
|
||||||
|
//! * [Chat on gitter](https://gitter.im/actix/actix)
|
||||||
|
//! * Cargo package: [actix-redis](https://crates.io/crates/actix-redis)
|
||||||
|
//! * Minimum supported Rust version: 1.21 or later
|
||||||
|
//!
|
||||||
extern crate actix;
|
extern crate actix;
|
||||||
extern crate backoff;
|
extern crate backoff;
|
||||||
extern crate futures;
|
extern crate futures;
|
||||||
@ -31,7 +40,7 @@ mod session;
|
|||||||
#[cfg(feature="web")]
|
#[cfg(feature="web")]
|
||||||
pub use session::RedisSessionBackend;
|
pub use session::RedisSessionBackend;
|
||||||
|
|
||||||
|
/// General purpose actix redis error
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[fail(display="Redis error {}", _0)]
|
#[fail(display="Redis error {}", _0)]
|
||||||
|
@ -17,6 +17,7 @@ use redis_async::resp::{RespCodec, RespValue};
|
|||||||
use Error;
|
use Error;
|
||||||
|
|
||||||
|
|
||||||
|
/// Command for send data to Redis
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Command(pub RespValue);
|
pub struct Command(pub RespValue);
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ pub struct RedisActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RedisActor {
|
impl RedisActor {
|
||||||
|
/// Start new `Supervisor` with `RedisActor`.
|
||||||
pub fn start<S: Into<String>>(addr: S) -> Addr<Unsync, RedisActor> {
|
pub fn start<S: Into<String>>(addr: S) -> Addr<Unsync, RedisActor> {
|
||||||
let addr = addr.into();
|
let addr = addr.into();
|
||||||
|
|
||||||
@ -69,7 +71,7 @@ impl Actor for RedisActor {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Can not connect to redis server: {}", err);
|
error!("Can not connect to redis server: {}", err);
|
||||||
// re-connect with backoff time.
|
// re-connect with backoff time.
|
||||||
// we stop currect context, supervisor will restart it.
|
// we stop current context, supervisor will restart it.
|
||||||
if let Some(timeout) = act.backoff.next_backoff() {
|
if let Some(timeout) = act.backoff.next_backoff() {
|
||||||
ctx.run_later(timeout, |_, ctx| ctx.stop());
|
ctx.run_later(timeout, |_, ctx| ctx.stop());
|
||||||
} else {
|
} else {
|
||||||
@ -80,7 +82,7 @@ impl Actor for RedisActor {
|
|||||||
.map_err(|err, act, ctx| {
|
.map_err(|err, act, ctx| {
|
||||||
error!("Can not connect to redis server: {}", err);
|
error!("Can not connect to redis server: {}", err);
|
||||||
// re-connect with backoff time.
|
// re-connect with backoff time.
|
||||||
// we stop currect context, supervisor will restart it.
|
// we stop current context, supervisor will restart it.
|
||||||
if let Some(timeout) = act.backoff.next_backoff() {
|
if let Some(timeout) = act.backoff.next_backoff() {
|
||||||
ctx.run_later(timeout, |_, ctx| ctx.stop());
|
ctx.run_later(timeout, |_, ctx| ctx.stop());
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user