All Projects → azuqua → fred.rs

azuqua / fred.rs

Licence: MIT License
A Redis Client for Rust based on Futures and Tokio

Programming Languages

rust
11053 projects
shell
77523 projects

Projects that are alternatives of or similar to fred.rs

Coerce Rs
Coerce - an asynchronous (async/await) Actor runtime and cluster framework for Rust
Stars: ✭ 231 (+138.14%)
Mutual labels:  cluster, tokio
kmedoids
The Partitioning Around Medoids (PAM) implementation of the K-Medoids algorithm in Python [Unmaintained]
Stars: ✭ 18 (-81.44%)
Mutual labels:  cluster
pulseha
PulseHA is a active-passive high availability cluster daemon that uses GRPC and is written in GO.
Stars: ✭ 15 (-84.54%)
Mutual labels:  cluster
core
augejs is a progressive Node.js framework for building applications. https://github.com/augejs/augejs.github.io
Stars: ✭ 18 (-81.44%)
Mutual labels:  cluster
endurox-go
Application Server for Go (ASG)
Stars: ✭ 32 (-67.01%)
Mutual labels:  cluster
kubernetes-marketplace
Marketplace of Kubernetes applications available for quick and easy installation in to Civo Kubernetes clusters
Stars: ✭ 136 (+40.21%)
Mutual labels:  cluster
racompass
An advanced GUI for Redis. Modern. Efficient. Fast. A faster and robust Redis management tool. For developers that need to manage data with confidence.It supports Redis modules now!
Stars: ✭ 26 (-73.2%)
Mutual labels:  cluster
saltstack-kubernetes
Deploy the lowest-cost production ready Kubernetes cluster using terraform and saltstack.
Stars: ✭ 47 (-51.55%)
Mutual labels:  cluster
dlaCluster
Python code for simple diffusion limited aggregation (DLA) simulation. The code provided creates a .gif for cluster growth and calculates fractal dimensionality of the cluster. User can vary the radius of the cluster.
Stars: ✭ 23 (-76.29%)
Mutual labels:  cluster
docker-rabbitmq-ha-cluster
A docker stack to create, test and benchmark a rabbitmq cluster in high availability configuration. HAProxy, php workers, node failures, network partition, persistent messages.
Stars: ✭ 98 (+1.03%)
Mutual labels:  cluster
memsocket
An asynchronous in-memory socket-like interface for Rust
Stars: ✭ 34 (-64.95%)
Mutual labels:  tokio
pacman.store
Pacman Mirror via IPFS for ArchLinux, Endeavouros and Manjaro
Stars: ✭ 65 (-32.99%)
Mutual labels:  cluster
tokio-linux-aio
Support for Linux kernel aio within Tokio.
Stars: ✭ 49 (-49.48%)
Mutual labels:  tokio
tiny-tokio-actor
A simple tiny actor library on top of Tokio
Stars: ✭ 28 (-71.13%)
Mutual labels:  tokio
init ec2
init EC2 cluster, for free-password-login(ubuntu and root). for hostname, for hosts file.
Stars: ✭ 11 (-88.66%)
Mutual labels:  cluster
jwt-redis-session
JSON Web Token Session Middleware
Stars: ✭ 74 (-23.71%)
Mutual labels:  azuqua-io-role-library
AMapMarker-master
提供一种高德地图自定义marker的解决方案以及改善高德官方点聚合功能
Stars: ✭ 63 (-35.05%)
Mutual labels:  cluster
ring-election
A node js library with a distributed leader/follower algorithm ready to be used
Stars: ✭ 92 (-5.15%)
Mutual labels:  cluster
dev-gateway
Local development cluster with "now" path aliases syntax support. Allows running multiple microservices as one solid server.
Stars: ✭ 32 (-67.01%)
Mutual labels:  cluster
minidb
A minimal in-memory distributed master-less document database
Stars: ✭ 29 (-70.1%)
Mutual labels:  cluster

Notice

This repository has moved to a new location. The crates.io location will not change, so nothing needs to change in your toml if you're using that.

The newest version is a complete rewrite on async/await, new tokio, etc. It also includes a number of new features and breaking changes to the API. See the new repository for more information.

Changes to the 2.x major version will be made here, if necessary, but all other development will happen in the new repository. When the 2.x major version is fully deprecated this repository will be archived.

Fred

LICENSE Build Status Crates.io API docs

A Redis client for Rust based on Futures and Tokio that supports PubSub commands, clustered Redis deployments, and more.

Install

With cargo edit.

cargo add fred

Features

  • Supports clustered Redis deployments.
  • Optional built-in reconnection logic with multiple backoff policies.
  • Publish-Subscribe interface.
  • Supports ElastiCache, including TLS support.
  • Gracefully handle live cluster rebalancing operations.
  • Flexible interfaces for different use cases.
  • Supports various scanning functions.
  • Automatically retry requests under bad network conditions.
  • Built-in tracking for network latency and payload size metrics.
  • Built-in mocking layer for running tests without a Redis server.
  • A client pooling interface to round-robin requests among a pool of connections.

Example

extern crate fred;
extern crate tokio_core;
extern crate futures;

use fred::RedisClient;
use fred::owned::RedisClientOwned;
use fred::types::*;

use tokio_core::reactor::Core;
use futures::{
  Future,
  Stream
};

fn main() {
  let config = RedisConfig::default();

  let mut core = Core::new().unwrap();
  let handle = core.handle();

  println!("Connecting to {:?}...", config);
  
  let client = RedisClient::new(config, None);
  let connection = client.connect(&handle);
  
  let commands = client.on_connect().and_then(|client| {
    println!("Client connected.");
    
    client.select(0)
  })
  .and_then(|client| {
    println!("Selected database.");
    
    client.info(None)
  })
  .and_then(|(client, info)| {
    println!("Redis server info: {}", info);
    
    client.get("foo")
  })
  .and_then(|(client, result)| {
    println!("Got foo: {:?}", result);
    
    client.set("foo", "bar", Some(Expiration::PX(1000)), Some(SetOptions::NX))
  })
  .and_then(|(client, result)| {
    println!("Set 'bar' at 'foo'? {}.", result);
    
    client.quit()
  });

  let (reason, client) = match core.run(connection.join(commands)) {
    Ok((r, c)) => (r, c),
    Err(e) => panic!("Connection closed abruptly: {}", e) 
  };

  println!("Connection closed gracefully with error: {:?}", reason);
}

See examples for more.

Redis Cluster

Clustered Redis deployments are supported by this module by specifying a RedisConfig::Clustered variant when using connect or connect_with_policy. When creating a clustered configuration only one valid host from the cluster is needed, regardless of how many nodes exist in the cluster. When the client first connects to a node it will use the CLUSTER NODES command to inspect the state of the cluster.

In order to simplify error handling and usage patterns this module caches the state of the cluster in memory and maintains connections to each node in the cluster. In the event that a node returns a MOVED or ASK error the client will pause to rebuild the in-memory cluster state. When the local cluster state and new connections have been fully rebuilt the client will begin processing commands again. Any requests sent while the in-memory cache is being rebuilt will be queued up and replayed when the connection is available again.

Additionally, this module will not acknowledge requests as having finished until a response arrives, so in the event that a connection dies while a request is in flight it will be retried multiple times (configurable via features below) when the connection comes back up.

Logging

This module uses pretty_env_logger for logging. To enable logs use the environment variable RUST_LOG with a value of trace, debug, warn, error, or info. See the documentation for env_logger for more information.

When a client is initialized it will generate a unique client name with a prefix of fred-. This name will appear in nearly all logging statements on the client in order to associate client and server operations if logging is enabled on both.

Elasticache and occasional NOAUTH errors

When using Amazon Elasticache and Redis auth, NOAUTH errors can occasionally occur even though the client has previously authenticated during the session. This prevents further commands from being processed successfully until the connection is rebuilt. While the exact cause of the NOAUTH response from Elasticache is not fully known, it can be worked around by using the reconnect-on-auth-error compiler feature. When enabled, NOAUTH errors are treated similarly to other general connection errors and if a reconnection policy is configured then the client will automatically rebuild the connection, re-auth and continue on with the previous command. By default this behaviour is not enabled.

Features

Name Default Description
enable-tls Enable TLS support. This requires OpenSSL (or equivalent) dependencies.
ignore-auth-error x Ignore auth errors that occur when a password is supplied but not required.
reconnect-on-auth-error A NOAUTH error is treated the same as a general connection failure and the client will reconnect based on the reconnection policy.
mocks Enable the mocking layer, which will use local memory instead of an actual redis server.
super-duper-bad-networking Increase the number of times a request will be automatically retried from 3 to 20. A request is retried when the connection closes while waiting on a response.

Environment Variables

Name Default Description
FRED_DISABLE_CERT_VERIFICATION false Disable certificate verification when using TLS features.

Tests

To run the unit and integration tests:

cargo test -- --test-threads=1

Note a local Redis server must be running on port 6379 and a clustered deployment must be running on ports 30001 - 30006 for the integration tests to pass.

Beware: the tests will periodically run flushall.

TODO

  • Expand the mocking layer to support all commands.
  • More commands.
  • Blocking commands.
  • Distribute reads among slaves.
  • Transactions.
  • Lua.

Contributing

See the contributing documentation for info on adding new commands. For anything more complicated feel free to file an issue and we'd be happy to point you in the right direction.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].