Skip to content

Commit

Permalink
Merge pull request #4 from juspay/cluster
Browse files Browse the repository at this point in the history
Cluster Support
  • Loading branch information
aravindgopall authored Feb 7, 2023
2 parents c0e8abe + 582e021 commit 10e07f3
Show file tree
Hide file tree
Showing 29 changed files with 2,172 additions and 595 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Main.hs
.stack-work
TAGS
stack*.yaml.lock
.vscode
29 changes: 18 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
language: c
# sudo: false
dist: bionic
dist: focal

# addons:
# apt:
# sources:
# - sourceline: ppa:redislabs/redis
# packages:
# - redis

cache:
directories:
- $HOME/.ghc
- $HOME/.cabal
- $HOME/.stack

services:
- docker

before_install:
- sudo apt-get update
- sudo apt-get -y install redis-server
- mkdir -p ~/.local/bin
- mkdir -p ~/tmp
- export PATH=~/.local/bin:$PATH
- curl -L https://github.com/commercialhaskell/stack/releases/download/v2.1.3/stack-2.1.3-linux-x86_64.tar.gz | tar xz -C ~/tmp
- mv ~/tmp/stack-2.1.3-linux-x86_64/stack ~/.local/bin/
# - curl -L https://github.com/antirez/redis/archive/5.0.2.tar.gz | tar xz -C ~/tmp
# - cd ~/tmp/redis-5.0.2 && make
# - ~/tmp/redis-5.0.2/src/redis-server &
- sudo add-apt-repository -y ppa:chris-lea/redis-server
- sudo apt-get update
- sudo apt-get -y install redis-server
- curl -L https://github.com/commercialhaskell/stack/releases/download/v2.5.1/stack-2.5.1-linux-x86_64.tar.gz | tar xz -C ~/tmp
- mv ~/tmp/stack-2.5.1-linux-x86_64/stack ~/.local/bin/
- cd ${TRAVIS_BUILD_DIR}
- docker run -d -p 7000-7010:7000-7010 grokzen/redis-cluster:5.0.6

matrix:
include:
# - env: GHCVER=7.10.3 STACK_YAML=stack-7.10.yaml
- env: GHCVER=8.0.1 STACK_YAML=stack-8.0.yaml
- env: GHCVER=8.2.2 STACK_YAML=stack-8.2.yaml
- env: GHCVER=8.4.1 STACK_YAML=stack-8.4.yaml
- env: GHCVER=8.6.5 STACK_YAML=stack-8.6.yaml
- env: GHCVER=8.8.1 STACK_YAML=stack-8.8.yaml
- env: GHCVER=8.10.4 STACK_YAML=stack-8.10.yaml
- env: GHCVER=8.10.6 STACK_YAML=stack-8.10.yaml

allow_failures:
- env: GHCVER=head STACK_YAML=stack-head.yaml
Expand Down
47 changes: 47 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,52 @@
# Changelog for Hedis

## 0.15.2
* PR #14. Updated with hedis upstream
* PR #13. Added timeout for commands
* PR #11. Send the command to another node while exception occurred on running the query.

## 0.15.1

* PR #181. Add MonadUnliftIO instance

## 0.15.0

* PR #174, Issue #173. Hedis fails to decode xstreamInfo response in case when the stream is empty

## 0.14.3

* PR #171. Support GHC 9

## 0.14.2

* PR #163. support for redis 6.0 COMMAND format
* PR #164. remove invalid tests for Redis Cluster

## 0.14.1

* PR #162. Improved documentation for EVALSHA

## 0.14.0

* PR #157. Clustering support

## 0.13.1

* PR #158. Upgrade to Redis 6.0.9 & Fix auth test
* PR #160. Fix GHC 8.0.1 compat

## 0.13.0

* PR #159. Issue #152. Make HSET return integer instead of bool

## 0.12.15

* PR #154. Implement Redis Sentinel support

## 0.12.14

* PR #153. Publicly expose ConnectTimeout exception

## 0.12.13

* PR #150, Issue #143. Leaking sockets when connection fails
Expand Down
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
./
2 changes: 1 addition & 1 deletion codegen/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@
],
"since": "2.0.0",
"group": "hash",
"returns": "bool"
"returns": "integer"
},
"HSETNX": {
"summary": "Set the value of a hash field, only if the field does not exist",
Expand Down
50 changes: 45 additions & 5 deletions hedis.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: hedis
version: 0.12.13
version: 0.15.2
synopsis:
Client library for the Redis datastore: supports full command set,
pipelining.
Expand Down Expand Up @@ -43,7 +43,7 @@ maintainer: Kostiantyn Rybnikov <[email protected]>
copyright: Copyright (c) 2011 Falko Peters
category: Database
build-type: Simple
cabal-version: >=1.8
cabal-version: >=1.10
homepage: https://github.com/informatikr/hedis
bug-reports: https://github.com/informatikr/hedis/issues
extra-source-files: CHANGELOG
Expand All @@ -58,6 +58,7 @@ flag dev
manual: True

library
default-language: Haskell2010
hs-source-dirs: src
ghc-options: -Wall -fwarn-tabs
if impl(ghc >= 8.6.0)
Expand All @@ -67,6 +68,7 @@ library
if flag(dev)
ghc-prof-options: -auto-all
exposed-modules: Database.Redis
, Database.Redis.Sentinel
, Database.Redis.Core.Internal
build-depends: scanner >= 0.2,
async >= 2.1,
Expand All @@ -75,6 +77,7 @@ library
bytestring-lexing >= 0.5,
exceptions,
unordered-containers,
containers,
text,
deepseq,
mtl >= 2,
Expand All @@ -86,22 +89,30 @@ library
vector >= 0.9,
HTTP,
errors,
network-uri
network-uri,
unliftio-core
if !impl(ghc >= 8.0)
build-depends:
semigroups >= 0.11 && < 0.19

other-modules: Database.Redis.Core,
Database.Redis.Connection,
Database.Redis.Cluster,
Database.Redis.Cluster.HashSlot,
Database.Redis.Cluster.Command,
Database.Redis.ProtocolPipelining,
Database.Redis.Protocol,
Database.Redis.PubSub,
Database.Redis.Transactions,
Database.Redis.Types
Database.Redis.Commands,
Database.Redis.ManualCommands,
Database.Redis.URL
Database.Redis.URL,
Database.Redis.ConnectionContext
other-extensions: StrictData

benchmark hedis-benchmark
default-language: Haskell2010
type: exitcode-stdio-1.0
main-is: benchmark/Benchmark.hs
build-depends:
Expand All @@ -116,10 +127,38 @@ benchmark hedis-benchmark
ghc-prof-options: -auto-all

test-suite hedis-test
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Test.hs
main-is: Main.hs
other-modules: PubSubTest
Tests
build-depends:
base == 4.*,
bytestring >= 0.10,
hedis,
HUnit,
async,
stm,
text,
mtl == 2.*,
test-framework,
test-framework-hunit,
time
-- We use -O0 here, since GHC takes *very* long to compile so many constants
ghc-options: -O0 -Wall -rtsopts -fno-warn-unused-do-bind
if flag(dev)
ghc-options: -Werror
if flag(dev)
ghc-prof-options: -auto-all

test-suite hedis-test-cluster
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: ClusterMain.hs
other-modules: PubSubTest
Tests
build-depends:
base == 4.*,
bytestring >= 0.10,
Expand All @@ -140,6 +179,7 @@ test-suite hedis-test
ghc-prof-options: -auto-all

test-suite doctest
default-language: Haskell2010
type: exitcode-stdio-1.0
main-is: DocTest.hs
ghc-options: -O0 -rtsopts
Expand Down
35 changes: 25 additions & 10 deletions src/Database/Redis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Database.Redis (
-- @
--
-- Send commands to the server:
--
--
-- @
-- {-\# LANGUAGE OverloadedStrings \#-}
-- ...
Expand Down Expand Up @@ -114,7 +114,7 @@ module Database.Redis (
-- The Redis Scripting website (<http://redis.io/commands/eval>)
-- documents the exact semantics of the scripting commands and value
-- conversion.

-- ** Automatic Pipelining
-- |Commands are automatically pipelined as much as possible. For example,
-- in the above \"hello world\" example, all four commands are pipelined.
Expand All @@ -130,7 +130,7 @@ module Database.Redis (
-- sent only when at least one reply has been received. That means, command
-- functions may block until there are less than 1000 outstanding replies.
--

-- ** Error Behavior
-- |
-- [Operations against keys holding the wrong kind of value:] Outside of a
Expand All @@ -155,7 +155,7 @@ module Database.Redis (
-- sure it is not left in an unusable state, e.g. closed or inside a
-- transaction.
--

-- * The Redis Monad
Redis(), runRedis,
unRedis, reRedis,
Expand All @@ -164,22 +164,24 @@ module Database.Redis (
-- * Connection
Connection, ConnectError(..), connect, checkedConnect, disconnect,
withConnect, withCheckedConnect,
ConnectInfo(..), defaultConnectInfo, parseConnectInfo,
ConnectInfo(..), defaultConnectInfo, parseConnectInfo, connectCluster,
PortID(..),

-- * Commands
module Database.Redis.Commands,

-- * Transactions
module Database.Redis.Transactions,

-- * Pub\/Sub
module Database.Redis.PubSub,

-- * Low-Level Command API
sendRequest,
sendToAllMasterNodes,
Reply(..),Status(..),RedisResult(..),ConnectionLostException(..),

ConnectTimeout(..),

-- |[Solution to Exercise]
--
-- Type of 'expire' inside a transaction:
Expand All @@ -190,15 +192,28 @@ module Database.Redis (
--
-- > lindex :: ByteString -> Integer -> Redis (Either Reply ByteString)
--
HashSlot, keyToSlot
) where

import Database.Redis.Core
import Database.Redis.Connection
( runRedis
, connectCluster
, defaultConnectInfo
, ConnectInfo(..)
, disconnect
, checkedConnect
, connect
, ConnectError(..)
, Connection(..)
, withConnect
, withCheckedConnect)
import Database.Redis.ConnectionContext(PortID(..), ConnectionLostException(..), ConnectTimeout(..))
import Database.Redis.PubSub
import Database.Redis.Protocol
import Database.Redis.ProtocolPipelining
(PortID(..), ConnectionLostException(..))
import Database.Redis.Transactions
import Database.Redis.Types
import Database.Redis.URL

import Database.Redis.Commands
import Database.Redis.Cluster.HashSlot(HashSlot, keyToSlot)
Loading

0 comments on commit 10e07f3

Please sign in to comment.