Skip to content

Commit ed7c2a3

Browse files
authored
Prepare test (#10)
1 parent 0ffebf8 commit ed7c2a3

File tree

7 files changed

+141
-5
lines changed

7 files changed

+141
-5
lines changed

.github/workflows/test.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
[![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)
23

3-
TODO
4+
Redis Cluster Client
45
===============================================================================
56

7+
TODO
8+
69
```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
811

912
cli.call('PING')
1013
#=> PONG

docker-compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
services:
33
node1: &node
4-
image: "redis:7"
4+
image: "redis:${REDIS_VERSION:-7}"
55
command: >
66
redis-server
77
--maxmemory 64mb
@@ -38,7 +38,7 @@ services:
3838
ports:
3939
- "7005:6379"
4040
clustering:
41-
image: "redis:7"
41+
image: "redis:${REDIS_VERSION:-7}"
4242
command: >
4343
bash -c "apt-get update > /dev/null
4444
&& apt-get install --no-install-recommends --no-install-suggests -y dnsutils > /dev/null

docs/CLASS_DIAGRAM.md renamed to docs/CLASS_DIAGRAMS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# [RedisClient](https://github.com/redis-rb/redis-client)
2+
13
```mermaid
24
classDiagram
35
class RedisClient {

docs/CLOUD_SERVICES.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
```

docs/SEQUENCE_DIAGRAMS.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
```

redis-cluster-client.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Gem::Specification.new do |s|
44
s.name = 'redis-cluster-client'
55
s.summary = 'A Redis cluster client for Ruby'
6-
s.version = '0.0.0'
6+
s.version = '0.0.1'
77
s.license = 'MIT'
88
s.homepage = 'https://github.com/redis-rb/redis-cluster-client'
99
s.authors = ['Taishi Kasuga']

0 commit comments

Comments
 (0)