• Stars
    star
    228
  • Rank 175,267 (Top 4 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Go redis cluster client built on top of redigo.

Go Reference Build Status

redisc

Package redisc implements a redis cluster client built on top of the redigo package. See the documentation for details.

Installation

$ go get [-u] [-t] github.com/mna/redisc

Releases

  • v1.3.2 : Export the HashSlots constant to make it nicer to write the Cluster.LayoutRefresh function signature.

  • v1.3.1 : Fix closing/releasing of connections used in Cluster.EachNode.

  • v1.3.0 : Add Cluster.EachNode to call a function with a connection for each known node in the cluster (e.g. to run diagnostics commands on each node or to collect all keys in a cluster); add optional Cluster function field BgError to receive notification of errors happening in background topology refreshes and on closing of RetryConn after following a redirection to a new connection; add optional Cluster function field LayoutRefresh to receive the old and new cluster slot mappings to server address(es); prevent unnecessary cluster layout refreshes when the internal mapping is the same as the redirection error; better handling of closed Cluster; move CI to Github Actions; drop support for old Go versions (currently tested on 1.15+); enable more static analysis/linters; refactor tests to create less separate clusters and run faster.

  • v1.2.0 : Use Go modules, fix a failing test due to changed error message on Redis 6.

  • v1.1.7 : Do not bind to a random node if Do is called without a command and the connection is not already bound (thanks to @tysonmote).

  • v1.1.6 : Append the actual error messages when a refresh returns "all nodes failed" error.

  • v1.1.5 : Add Cluster.PoolWaitTime to configure the time to wait on a connection from a pool with MaxActive > 0 and Wait set to true (thanks to @iwanbk).

  • v1.1.4 : Add Conn.DoWithTimeout and Conn.ReceiveWithTimeout to match redigo's ConnWithTimeout interface (thanks to @letsfire).

  • v1.1.3 : Fix handling of ASK replies in RetryConn.

  • v1.1.2 : Remove mention that StartupNodes in Cluster struct needs to be master nodes (it can be replicas). Add supporting test.

  • v1.1.1 : Fix CI tests.

  • v1.1.0 : This release builds with the github.com/gomodule/redigo package (the new import path of redigo, which also has a breaking change in its v2.0.0, the PMessage type has been removed and consolidated into Message).

  • v1.0.0 : This release builds with the github.com/garyburd/redigo package, which - according to its readme - will not be maintained anymore, having moved to github.com/gomodule/redigo for future development. As such, redisc will not be updated with the old redigo package, this version was created only to avoid causing issues to users of redisc.

Documentation

The code documentation is the canonical source for documentation.

The design goal of redisc is to be as compatible as possible with the redigo package. As such, the Cluster type can be used as a drop-in replacement to a redis.Pool when moving from a standalone Redis to a Redis Cluster setup, and the connections returned by the cluster implement redigo's redis.Conn interface. The package offers additional features specific to dealing with a cluster that may be needed for more advanced scenarios.

The main features are:

  • Drop-in replacement for redis.Pool (the Cluster type implements the same Get and Close method signatures).
  • Connections are redis.Conn interfaces and use the redigo package to execute commands, redisc only handles the cluster part.
  • Support for all cluster-supported commands including scripting, transactions and pub-sub (within the limitations imposed by Redis Cluster).
  • Support for READONLY/READWRITE commands to allow reading data from replicas.
  • Client-side smart routing, automatically keeps track of which node holds which key slots.
  • Automatic retry of MOVED, ASK and TRYAGAIN errors when desired, via RetryConn.
  • Manual handling of redirections and retries when desired, via IsTryAgain and ParseRedir.
  • Automatic detection of the node to call based on the command's first parameter (assumed to be the key).
  • Explicit selection of the node to call via BindConn when needed.
  • Support for optimal batch calls via SplitBySlot.

Note that to make efficient use of Redis Cluster, some upfront work is usually required. A good understanding of Redis Cluster is highly recommended and the official Redis website has good documentation that covers this. In particular, Migrating to Redis Cluster will help understand how straightforward (or not) the migration may be for your specific case.

Alternatives

Support

There are a number of ways you can support the project:

  • Use it, star it, build something with it, spread the word!
  • Raise issues to improve the project (note: doc typos and clarifications are issues too!)
    • Please search existing issues before opening a new one - it may have already been adressed.
  • Pull requests: please discuss new code in an issue first, unless the fix is really trivial.
    • Make sure new code is tested.
    • Be mindful of existing code - PRs that break existing code have a high probability of being declined, unless it fixes a serious issue.
  • Sponsor the developer
    • See the Github Sponsor button at the top of the repo on github

License

The BSD 3-Clause license.

More Repositories

1

pigeon

Command pigeon generates parsers in Go from a PEG grammar.
Go
837
star
2

agora

a dynamically typed, garbage collected, embeddable programming language built with Go
Go
326
star
3

martini-api-example

An example RESTful API application built with Martini.
Go
272
star
4

trofaf

Super simple live static blog generator in Go. Vraiment trofaf.
CSS
130
star
5

express-boilerplate

Basic structure of a node.js web application with Express. Started out as a blog post about how to structure code in an Express web app (in French, see the URL below).
JavaScript
64
star
6

juggler

Juggler: a websocket-based, redis-backed RPC and pub-sub server.
Go
62
star
7

gocostmodel

Benchmarks of common basic operations for the Go language.
Go
61
star
8

specter

a (tiny) VM project built with Go
Go
59
star
9

ghost

Lego blocks for web servers.
Go
52
star
10

lune

A pure Go implementation of the Lua virtual machine.
Go
44
star
11

advice

Advice functional mixin based on Twitter's Angus Croll presentation (How we learned to stop worrying and love Javascript).
JavaScript
39
star
12

upstashdis

A Go client and a compatible server for local testing for the Upstash Redis REST API interface.
Go
22
star
13

gred

A pure Go concurrent implementation of the Redis server
Go
20
star
14

implement.js

Strong type-checking for dependency injection and method arguments.
JavaScript
20
star
15

Networking

Low-level Swift package for POSIX sockets and Epoll/Kqueue.
Swift
19
star
16

luashell

A small Lua module to help write what would be shell scripts in Lua. (mirror)
Lua
12
star
17

gocoro

Lua coroutine implementation in Go
Go
7
star
18

angular-gtd

An example app for Getting Things Done built with AngularJS.
JavaScript
6
star
19

tulip

Lua web framework based on lua-http and PostgreSQL. (mirror)
Lua
6
star
20

algo

Fundamental algorithms and data structures using Go generics.
Go
6
star
21

mainer

Package mainer defines types relevant to flag parsing and command entrypoint implementation.
Go
5
star
22

assnatapi

API pour exploiter les données de l'Assemblée nationale du Québec.
JavaScript
5
star
23

starstruct

Starlark to Go struct converter.
Go
4
star
24

assnat

Extracteur des données du site de l'Assemblée Nationale du Québec, pour nourrir assnatapi.
JavaScript
4
star
25

swiftodo

iOS ToDo list tutorial in Swift
Swift
4
star
26

httpcmw

Package httpcmw supports creating middleware chains for HTTP clients.
Go
3
star
27

runes

Command to print Unicode code point information.
Go
3
star
28

myvim

my vim setup
Vim Script
2
star
29

zzterm

Zero-allocation terminal input key and mouse decoder in Go (mirror).
Go
2
star
30

nitfind

ack-style finder in Nit, mostly to experiment with the language
Nit
2
star
31

setupjs

Personal setup for javascript frontend projects.
JavaScript
2
star
32

see-no-evil

Tiny callback cleaner library for node.js, so that error management gets out of the way.
JavaScript
2
star
33

httpmw

Package httpmw is a collection of bite-sized middleware with chaining support.
Go
2
star
34

bench_go_scripting

Small benchmarks comparing the Tengo and Risor scripting languages
Shell
2
star
35

luafn

Functional programming fundamentals for Lua. (mirror)
Lua
1
star
36

sendkeys

Simulate sending user input in a terminal (mirror).
Go
1
star
37

luasock99

Lua module for the socket99 C library. (mirror)
C
1
star
38

nenuphar

wip
Go
1
star
39

bookify

Make a book out of URLs, basically. Exploring node.js, express and socket.io along the way!
JavaScript
1
star
40

tcheck

Simple Lua module of sanity-checks for types (mirror)
Lua
1
star
41

Provok.in-issues

Issues repository for the Provok.in website.
1
star
42

exp

Go
1
star
43

xpgsql

Lua module providing a straightforward API to the luapgsql library. (mirror)
Lua
1
star
44

feedbuilder

JavaScript
1
star
45

mna.dev

Mirror of git.sr.ht/~mna/mna.dev
Go
1
star
46

vim-trefle

Vim syntax highlighting, filetype detection and indentation for trefle.
Vim Script
1
star
47

0value

files for my 0value.com blog
HTML
1
star
48

zzcsi

Control Sequence Introducer (CSI) functions for xterm-compatible terminals. (mirror)
Go
1
star
49

httpparms

Package httpparms provides helper functions and mechanisms to load the content of an HTTP request into a Go struct.
Go
1
star
50

ungeekenorbite

Blog exploratoire d'un geek qui découvre avec stupeur et tremblements le merveilleux monde des nouvelles technologies.
JavaScript
1
star