File tree Expand file tree Collapse file tree 7 files changed +141
-5
lines changed Expand file tree Collapse file tree 7 files changed +141
-5
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ # @see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
3
+ name : Test
4
+ on :
5
+ push :
6
+ branches :
7
+ - ' *'
8
+ pull_request :
9
+ branches :
10
+ - ' *'
11
+ jobs :
12
+ lint :
13
+ name : Lint
14
+ timeout-minutes : 10
15
+ runs-on : ubuntu-latest
16
+ steps :
17
+ - name : Check out code
18
+ uses : actions/checkout@v3
19
+ - name : Set up Ruby
20
+ uses : ruby/setup-ruby@v1
21
+ with :
22
+ ruby-version : ' 3.1'
23
+ bundler-cache : true
24
+ - name : Run rubocop
25
+ run : bundle exec rubocop
26
+ main :
27
+ name : Main
28
+ timeout-minutes : 30
29
+ strategy :
30
+ fail-fast : false
31
+ matrix :
32
+ os : ['ubuntu-latest']
33
+ redis : ['6.2.7', '7.0.1']
34
+ ruby : ['3.1', '3.0', '2.7']
35
+ runs-on : ${{ matrix.os }}
36
+ env :
37
+ REDIS_VERSION : ${{ matrix.redis }}
38
+ steps :
39
+ - name : Check out code
40
+ uses : actions/checkout@v3
41
+ - name : Set up Ruby
42
+ uses : ruby/setup-ruby@v1
43
+ with :
44
+ ruby-version : ${{ matrix.ruby }}
45
+ bundler-cache : true
46
+ # Services feature of GitHub Actions isn't fit for our purposes for testing.
47
+ # We cannot overwrite arguments of ENTRYPOINT.
48
+ # @see https://docs.docker.com/engine/reference/commandline/create/#options
49
+ - name : Pull Docker images
50
+ run : docker pull redis:$REDIS_VERSION
51
+ - name : Docker compose up
52
+ run : docker compose up -d
53
+ - name : Wait for Redis cluster to be ready
54
+ run : docker compose ps
55
+ - name : Run minitest
56
+ run : bundle exec rake test
Original file line number Diff line number Diff line change 1
1
[ ![ Gem Version] ( https://badge.fury.io/rb/redis-cluster-client.svg )] ( https://badge.fury.io/rb/redis-cluster-client )
2
+ ![ Test status] ( https://github.com/redis-rb/redis-cluster-client/workflows/Test/badge.svg?branch=master )
2
3
3
- TODO
4
+ Redis Cluster Client
4
5
===============================================================================
5
6
7
+ TODO
8
+
6
9
``` ruby
7
- cli = RedisClient .cluster(nodes: %w[redis://127.0.0.1:7000] , replica: false ).new_client
10
+ cli = RedisClient .cluster(nodes: %w[redis://127.0.0.1:7000] ).new_client
8
11
9
12
cli.call(' PING' )
10
13
# => PONG
Original file line number Diff line number Diff line change 1
1
---
2
2
services :
3
3
node1 : &node
4
- image : " redis:7 "
4
+ image : " redis:${REDIS_VERSION:-7} "
5
5
command : >
6
6
redis-server
7
7
--maxmemory 64mb
@@ -38,7 +38,7 @@ services:
38
38
ports :
39
39
- " 7005:6379"
40
40
clustering :
41
- image : " redis:7 "
41
+ image : " redis:${REDIS_VERSION:-7} "
42
42
command : >
43
43
bash -c "apt-get update > /dev/null
44
44
&& apt-get install --no-install-recommends --no-install-suggests -y dnsutils > /dev/null
Original file line number Diff line number Diff line change
1
+ # [ RedisClient] ( https://github.com/redis-rb/redis-client )
2
+
1
3
``` mermaid
2
4
classDiagram
3
5
class RedisClient {
Original file line number Diff line number Diff line change
1
+ # Architectures of Redis cluster with SSL/TLS as imagined
2
+
3
+ ## AWS
4
+ The client can connect to the nodes directly.
5
+ The endpoint is just a CNAME record of DNS.
6
+ It is as simple as that.
7
+
8
+ ``` mermaid
9
+ graph TB
10
+ client(Cluster Client)
11
+
12
+ subgraph Amazon ElastiCache for Redis
13
+ node0(Node0)
14
+ node1(Node1)
15
+ node2(Node2)
16
+ end
17
+
18
+ node0-.-node1-.-node2-.-node0
19
+ client--rediss://node0.example.com:6379-->node0
20
+ client--rediss://node1.example.com:6379-->node1
21
+ client--rediss://node2.example.com:6379-->node2
22
+ ```
23
+
24
+ ## Microsoft Azure
25
+ The service provides a single IP address and multiple ports mapped to each node.
26
+ The endpoint doesn't support redirection.
27
+ It does only SSL/TLS termination.
28
+
29
+ ``` mermaid
30
+ graph TB
31
+ client(Cluster Client)
32
+
33
+ subgraph Azure Cache for Redis
34
+ subgraph Endpoint
35
+ endpoint(Active)
36
+ endpoint_sb(Standby)
37
+ end
38
+
39
+ subgraph Cluster
40
+ node0(Node0)
41
+ node1(Node1)
42
+ node2(Node2)
43
+ end
44
+ end
45
+
46
+ endpoint-.-endpoint_sb
47
+ node0-.-node1-.-node2-.-node0
48
+ client--rediss://endpoint.example.com:15000-->endpoint--redis://node0:6379-->node0
49
+ client--rediss://endpoint.example.com:15001-->endpoint--redis://node1:6379-->node1
50
+ client--rediss://endpoint.example.com:15002-->endpoint--redis://node2:6379-->node2
51
+ ```
Original file line number Diff line number Diff line change
1
+ # How does cluster client work?
2
+
3
+ ``` mermaid
4
+ sequenceDiagram
5
+ participant Client
6
+ participant Server Shard 1
7
+ participant Server Shard 2
8
+ participant Server Shard 3
9
+ Note over Client,Server Shard 3: Redis.new(cluster: %w[redis://node1:6379])
10
+ Client->>+Server Shard 1: CLUSTER SLOTS
11
+ Server Shard 1-->>-Client: nodes and slots data
12
+ Client->>+Server Shard 1: GET key1
13
+ Server Shard 1-->>-Client: value1
14
+ Client->>+Server Shard 2: GET key2
15
+ Server Shard 2-->>-Client: value2
16
+ Client->>+Server Shard 3: GET key3
17
+ Server Shard 3-->>-Client: value3
18
+ Client->>+Server Shard 3: GET key1
19
+ Server Shard 3-->>-Client: MOVED Server Shard 1
20
+ Note over Client,Server Shard 3: Client needs to redirect to correct node
21
+ Client->>+Server Shard 2: MGET key2 key3
22
+ Server Shard 2-->>-Client: CROSSSLOTS
23
+ Note over Client,Server Shard 2: Cannot command across shards
24
+ ```
Original file line number Diff line number Diff line change 3
3
Gem ::Specification . new do |s |
4
4
s . name = 'redis-cluster-client'
5
5
s . summary = 'A Redis cluster client for Ruby'
6
- s . version = '0.0.0 '
6
+ s . version = '0.0.1 '
7
7
s . license = 'MIT'
8
8
s . homepage = 'https://github.com/redis-rb/redis-cluster-client'
9
9
s . authors = [ 'Taishi Kasuga' ]
You can’t perform that action at this time.
0 commit comments