-
Notifications
You must be signed in to change notification settings - Fork 7
added get_replica_connections function #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 33 commits
e7beff6
6a717ab
0791c7e
c77580e
5ee68b7
c4dc33a
2c20a1e
99b6671
dd8a4ad
8eed87f
e646320
4a3d585
a1262e0
199a1e5
71622fe
9f261fc
9d21e95
6aad7bd
2a96be0
b693987
519b9dd
557f04f
222cfb4
a9f597e
ac8471e
cfd0864
65e41d0
d112322
ad7cedd
ac4cfa4
5a444db
4cc0b6a
51d4d90
cb8cd2e
1ad3162
4d4c1ac
263e8bf
af4f748
b1d6c41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,15 +8,7 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: Test with Python ${{ matrix.python }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| services: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| falkordb: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Docker Hub image | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| image: falkordb/falkordb:edge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Map port 6379 on the Docker host to port 6379 on the FalkorDB container | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 6379:6379 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| strategy: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| matrix: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| python: ['3.8', '3.10', '3.11'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -25,9 +17,36 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Run docker-compose for redis standalone instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: hoverkraft-tech/compose-action@v2.0.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| compose-file: ./docker/standalone-compose.yml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Run docker-compose for redis replication instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: hoverkraft-tech/compose-action@v2.0.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| compose-file: ./docker/sentinel-compose.yml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Run docker-compose for redis cluster instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: hoverkraft-tech/compose-action@v2.0.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| compose-file: ./docker/cluster-compose.yml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add health check for cluster setup Add health check for cluster setup as well. Apply this diff: - name: Run docker-compose for redis cluster instance
uses: hoverkraft-tech/compose-action@v2.0.1
with:
compose-file: ./cluster-compose
+ - name: Wait for cluster to be ready
+ run: |
+ timeout 30s bash -c 'until docker exec node0 redis-cli -p 5000 cluster info; do sleep 1; done'📝 Committable suggestion
Suggested change
🧰 Tools🪛 yamllint (1.35.1)[error] 34-34: trailing spaces (trailing-spaces)
Comment on lines
+20
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add health checks before proceeding with tests The workflow should wait for the services to be healthy before proceeding with tests. Apply this diff: - name: Run docker-compose for redis standalone instance
uses: hoverkraft-tech/compose-action@v2.0.1
with:
compose-file: ./docker/standalone-compose.yml
+ - name: Wait for standalone to be ready
+ run: |
+ timeout 30s bash -c 'until docker exec redis-standalone redis-cli ping; do sleep 1; done'
- name: Run docker-compose for redis replication instance
uses: hoverkraft-tech/compose-action@v2.0.1
with:
compose-file: ./docker/sentinel-compose.yml
+ - name: Wait for sentinel to be ready
+ run: |
+ timeout 30s bash -c 'until docker exec sentinel-1 redis-cli -p 26379 ping; do sleep 1; done'
- name: Run docker-compose for redis cluster instance
uses: hoverkraft-tech/compose-action@v2.0.1
with:
compose-file: ./docker/cluster-compose.yml
+ - name: Wait for cluster to be ready
+ run: |
+ timeout 30s bash -c 'until docker exec node0 redis-cli -p 5000 cluster info; do sleep 1; done'📝 Committable suggestion
Suggested change
🧰 Tools🪛 yamllint (1.35.1)[error] 34-34: trailing spaces (trailing-spaces) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Add entries to the host file to correctly resolve service names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo echo "127.0.0.1 redis-standalone" | sudo tee -a /etc/hosts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo echo "127.0.0.1 sentinel-1" | sudo tee -a /etc/hosts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo echo "127.0.0.1 sentinel-2" | sudo tee -a /etc/hosts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo echo "127.0.0.1 sentinel-3" | sudo tee -a /etc/hosts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo echo "127.0.0.1 redis-server-1" | sudo tee -a /etc/hosts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo echo "127.0.0.1 redis-server-2" | sudo tee -a /etc/hosts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for i in node{0..5};do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "127.0.0.1 $i" | sudo tee -a /etc/hosts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - uses: actions/setup-python@v5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| python-version: ${{matrix.python}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| python-version: ${{ matrix.python }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - uses: snok/install-poetry@v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -37,6 +56,9 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: poetry install --no-interaction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: install docker-compose client | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: sudo apt update && sudo apt install docker-compose -y | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Run Tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: poetry run pytest --cov --cov-report=xml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -46,4 +68,4 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: matrix.python == '3.10' && matrix.platform != 'macos-11' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fail_ci_if_error: false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| token: ${{ secrets.CODECOV_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| token: ${{ secrets.CODECOV_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
71
to
+74
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix undefined matrix variable The - name: Upload coverage
uses: codecov/codecov-action@v5
- if: matrix.python == '3.10' && matrix.platform != 'macos-11'
+ if: matrix.python == '3.10'
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.4)80-80: property "platform" is not defined in object type {python: number} (expression) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| services: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add dedicated cluster initialization service A separate service should handle cluster initialization after all nodes are healthy. cluster-init:
image: falkordb/falkordb:latest
command: >
/bin/bash -c "
echo 'Waiting for nodes to be ready...' &&
sleep 10 &&
redis-cli --cluster create node0:5000 node1:6000 node2:7000 node3:8000 node4:9000 node5:10000 --cluster-replicas 1 --cluster-yes
"
networks:
- redis-cluster
depends_on:
node0:
condition: service_healthy
node1:
condition: service_healthy
node2:
condition: service_healthy
node3:
condition: service_healthy
node4:
condition: service_healthy
node5:
condition: service_healthy |
||
| node0: | ||
| image: falkordb/falkordb:latest | ||
| container_name: node0 | ||
| hostname: node0 | ||
| ports: | ||
| - 5000:5000 | ||
| networks: | ||
| - redis-cluster | ||
| healthcheck: | ||
| test: | | ||
| redis-cli --cluster create node0:5000 node1:6000 \ | ||
| node2:7000 node3:8000 node4:9000 node5:10000 --cluster-replicas 1 --cluster-yes || echo failed && exit 1 | ||
| interval: 3s | ||
| timeout: 10s | ||
| retries: 10 | ||
| start_period: 2s | ||
|
||
| entrypoint: /bin/bash | ||
|
||
| command: | ||
| - -c | ||
| - | | ||
| touch /data/node.conf | ||
| echo "port 5000" >> /data/node.conf | ||
| echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf | ||
| echo "cluster-preferred-endpoint-type hostname" >> /data/node.conf | ||
| echo "cluster-port 16379" >> /data/node.conf | ||
| echo "cluster-enabled yes" >> /data/node.conf | ||
| echo "cluster-config-file /data/nodes.conf" >> /data/node.conf | ||
| echo "cluster-node-timeout 5000" >> /data/node.conf | ||
| echo "cluster-announce-hostname node0" >> /data/node.conf | ||
| redis-server /data/node.conf | ||
|
||
| node1: | ||
| image: falkordb/falkordb:latest | ||
| container_name: node1 | ||
| hostname: node1 | ||
| ports: | ||
| - 6000:6000 | ||
| networks: | ||
| - redis-cluster | ||
| entrypoint: /bin/bash | ||
| command: | ||
| - -c | ||
| - | | ||
| touch /data/node.conf | ||
| echo "port 6000" >> /data/node.conf | ||
| echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf | ||
| echo "cluster-preferred-endpoint-type hostname" >> /data/node.conf | ||
| echo "cluster-port 16379" >> /data/node.conf | ||
| echo "cluster-enabled yes" >> /data/node.conf | ||
| echo "cluster-config-file /data/nodes.conf" >> /data/node.conf | ||
| echo "cluster-node-timeout 5000" >> /data/node.conf | ||
| echo "cluster-announce-hostname node1" >> /data/node.conf | ||
| redis-server /data/node.conf | ||
| node2: | ||
| image: falkordb/falkordb:latest | ||
| container_name: node2 | ||
| hostname: node2 | ||
| ports: | ||
| - 7000:7000 | ||
| networks: | ||
| - redis-cluster | ||
| entrypoint: /bin/bash | ||
| command: | ||
| - -c | ||
| - | | ||
| touch /data/node.conf | ||
| echo "port 7000" >> /data/node.conf | ||
| echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf | ||
| echo "cluster-preferred-endpoint-type hostname" >> /data/node.conf | ||
| echo "cluster-port 16379" >> /data/node.conf | ||
| echo "cluster-enabled yes" >> /data/node.conf | ||
| echo "cluster-config-file /data/nodes.conf" >> /data/node.conf | ||
| echo "cluster-node-timeout 5000" >> /data/node.conf | ||
| echo "cluster-announce-hostname node2" >> /data/node.conf | ||
| redis-server /data/node.conf | ||
| node3: | ||
| image: falkordb/falkordb:latest | ||
| container_name: node3 | ||
| hostname: node3 | ||
| ports: | ||
| - 8000:8000 | ||
| networks: | ||
| - redis-cluster | ||
| entrypoint: /bin/bash | ||
| command: | ||
| - -c | ||
| - | | ||
| touch /data/node.conf | ||
| echo "port 8000" >> /data/node.conf | ||
| echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf | ||
| echo "cluster-preferred-endpoint-type hostname" >> /data/node.conf | ||
| echo "cluster-port 16379" >> /data/node.conf | ||
| echo "cluster-enabled yes" >> /data/node.conf | ||
| echo "cluster-config-file /data/nodes.conf" >> /data/node.conf | ||
| echo "cluster-node-timeout 5000" >> /data/node.conf | ||
| echo "cluster-announce-hostname node3" >> /data/node.conf | ||
| redis-server /data/node.conf | ||
| node4: | ||
| image: falkordb/falkordb:latest | ||
| container_name: node4 | ||
| hostname: node4 | ||
| ports: | ||
| - 9000:9000 | ||
| networks: | ||
| - redis-cluster | ||
| entrypoint: /bin/bash | ||
| command: | ||
| - -c | ||
| - | | ||
| touch /data/node.conf | ||
| echo "port 9000" >> /data/node.conf | ||
| echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf | ||
| echo "cluster-preferred-endpoint-type hostname" >> /data/node.conf | ||
| echo "cluster-port 16379" >> /data/node.conf | ||
| echo "cluster-enabled yes" >> /data/node.conf | ||
| echo "cluster-config-file /data/nodes.conf" >> /data/node.conf | ||
| echo "cluster-node-timeout 5000" >> /data/node.conf | ||
| echo "cluster-announce-hostname node4" >> /data/node.conf | ||
| redis-server /data/node.conf | ||
|
|
||
| node5: | ||
| image: falkordb/falkordb:latest | ||
| container_name: node5 | ||
| hostname: node5 | ||
| ports: | ||
| - 10000:10000 | ||
| networks: | ||
| - redis-cluster | ||
| entrypoint: /bin/bash | ||
| command: | ||
| - -c | ||
| - | | ||
| touch /data/node.conf | ||
| echo "port 10000" >> /data/node.conf | ||
| echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf | ||
| echo "cluster-preferred-endpoint-type hostname" >> /data/node.conf | ||
| echo "cluster-port 16379" >> /data/node.conf | ||
| echo "cluster-enabled yes" >> /data/node.conf | ||
| echo "cluster-config-file /data/nodes.conf" >> /data/node.conf | ||
| echo "cluster-node-timeout 5000" >> /data/node.conf | ||
| echo "cluster-announce-hostname node5" >> /data/node.conf | ||
| redis-server /data/node.conf | ||
|
||
|
|
||
|
|
||
| networks: | ||
| redis-cluster: | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,108 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| services: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sentinel-1: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| image: falkordb/falkordb:latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| container_name: sentinel-1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hostname: sentinel-1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| restart: always | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| networks: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - redis-sentinel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 26379:26379 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| entrypoint: /bin/bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| command: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - -c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| touch /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel monitor master redis-server-1 6380 2" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel announce-hostnames yes" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel announce-ip sentinel-1" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel resolve-hostnames yes" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel announce-port 26379" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "port 26379" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis-server /data/sentinel.conf --sentinel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+2
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add health checks for sentinel services. The sentinel services should have health checks to ensure they're properly initialized. Apply this diff to all sentinel services: sentinel-1:
image: bitnami/redis-sentinel
container_name: sentinel-1
hostname: sentinel-1
restart: always
+ healthcheck:
+ test: ["CMD", "redis-cli", "-p", "26379", "ping"]
+ interval: 5s
+ timeout: 3s
+ retries: 3
networks:
- redis-sentinel📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sentinel-2: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| image: falkordb/falkordb:latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| container_name: sentinel-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hostname: sentinel-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| restart: always | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| networks: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - redis-sentinel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 26380:26380 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| entrypoint: /bin/bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| command: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - -c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| touch /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel monitor master redis-server-1 6380 2" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel announce-hostnames yes" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel announce-ip sentinel-2" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel resolve-hostnames yes" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel announce-port 26380" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "port 26380" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis-server /data/sentinel.conf --sentinel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sentinel-3: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| image: falkordb/falkordb:latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| container_name: sentinel-3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hostname: sentinel-3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| restart: always | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| networks: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - redis-sentinel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 26381:26381 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| entrypoint: /bin/bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| command: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - -c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| touch /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel monitor master redis-server-1 6380 2" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel announce-hostnames yes" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel announce-ip sentinel-3" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel resolve-hostnames yes" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "sentinel announce-port 26381" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "port 26381" >> /data/sentinel.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis-server /data/sentinel.conf --sentinel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+2
to
+64
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add health checks and improve reliability for sentinel services. The sentinel services need several improvements for production readiness:
Apply these changes to all sentinel services: sentinel-1:
image: falkordb/falkordb:latest
container_name: sentinel-1
hostname: sentinel-1
restart: always
+ healthcheck:
+ test: ["CMD", "redis-cli", "-p", "26379", "ping"]
+ interval: 5s
+ timeout: 3s
+ retries: 3
+ depends_on:
+ redis-server-1:
+ condition: service_healthy
+ volumes:
+ - ./sentinel1.conf:/data/sentinel.conf:ro
networks:
- redis-sentinel
ports:
- 26379:26379
- entrypoint: /bin/bash
- command:
- - -c
- - |
- touch /data/sentinel.conf
- echo "sentinel monitor master redis-server-1 6380 2" >> /data/sentinel.conf
- echo "sentinel announce-hostnames yes" >> /data/sentinel.conf
- echo "sentinel announce-ip sentinel-1" >> /data/sentinel.conf
- echo "sentinel resolve-hostnames yes" >> /data/sentinel.conf
- echo "sentinel announce-port 26379" >> /data/sentinel.conf
- echo "port 26379" >> /data/sentinel.conf
- redis-server /data/sentinel.conf --sentinelCreate external configuration files for better maintainability: 🧰 Tools🪛 yamllint (1.35.1)[error] 13-13: trailing spaces (trailing-spaces) [error] 45-45: trailing spaces (trailing-spaces)
Comment on lines
+1
to
+64
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add health checks and improve sentinel configuration. The sentinel services lack health checks and have duplicated configuration. sentinel-1:
image: bitnami/redis-sentinel
container_name: sentinel-1
hostname: sentinel-1
restart: always
+ healthcheck:
+ test: ["CMD", "redis-cli", "-p", "26379", "ping"]
+ interval: 5s
+ timeout: 3s
+ retries: 3
+ depends_on:
+ redis-server-1:
+ condition: service_healthy
networks:
- redis-sentinelApply similar changes to x-sentinel-base: &sentinel-base
image: bitnami/redis-sentinel
restart: always
networks:
- redis-sentinel
healthcheck: &healthcheck
test: ["CMD", "redis-cli", "-p", "26379", "ping"]
interval: 5s
timeout: 3s
retries: 3🧰 Tools🪛 yamllint (1.35.1)[error] 43-43: trailing spaces (trailing-spaces) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis-server-1: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| image: falkordb/falkordb:latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hostname: redis-server-1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| container_name: redis-server-1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 6380:6380 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| networks: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - redis-sentinel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| entrypoint: /bin/bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| command: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - -c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| touch /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "port 6380" >> /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "replica-announce-ip redis-server-1" >> /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "replica-announce-port 6380" >> /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis-server /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+62
to
+77
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve Redis master server configuration The Redis master server configuration needs improvements:
Add the following configurations: redis-server-1:
image: falkordb/falkordb:edge
hostname: redis-server-1
container_name: redis-server-1
+ restart: always
+ healthcheck:
+ test: ["CMD", "redis-cli", "-p", "6380", "ping"]
+ interval: 5s
+ timeout: 3s
+ retries: 3
+ volumes:
+ - redis_data:/data
ports:
- 6380:6380
networks:
- redis-sentinelAdd at the end of the file: volumes:
redis_data:🧰 Tools🪛 yamllint (1.35.1)[error] 73-73: trailing spaces (trailing-spaces) [error] 78-78: trailing spaces (trailing-spaces)
Comment on lines
+68
to
+77
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve Redis master server configuration The Redis master configuration needs several improvements for production readiness:
Apply these changes: redis-server-1:
- image: falkordb/falkordb:edge
+ image: falkordb/falkordb:latest
hostname: redis-server-1
container_name: redis-server-1
+ restart: always
+ healthcheck:
+ test: ["CMD", "redis-cli", "-p", "6380", "ping"]
+ interval: 5s
+ timeout: 3s
+ retries: 3
+ volumes:
+ - redis_master_data:/data
+ - ./master.conf:/data/node.conf:ro
ports:
- 6380:6380
networks:
- redis-sentinelAdd at the end of the file: volumes:
redis_master_data:🧰 Tools🪛 yamllint (1.35.1)[error] 81-81: trailing spaces (trailing-spaces) [error] 86-86: trailing spaces (trailing-spaces)
Comment on lines
+68
to
+77
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve Redis master server configuration. The Redis master server configuration needs several improvements for production readiness:
Apply these changes: redis-server-1:
image: falkordb/falkordb:latest
hostname: redis-server-1
container_name: redis-server-1
+ restart: always
+ healthcheck:
+ test: ["CMD", "redis-cli", "-p", "6380", "ping"]
+ interval: 5s
+ timeout: 3s
+ retries: 3
+ volumes:
+ - redis_master_data:/data
+ - ./master.conf:/data/node.conf:ro
ports:
- 6380:6380
networks:
- redis-sentinel
- entrypoint: /bin/bash
- command:
- - -c
- - |
- touch /data/node.conf
- echo "port 6380" >> /data/node.conf
- echo "replica-announce-ip redis-server-1" >> /data/node.conf
- echo "replica-announce-port 6380" >> /data/node.conf
- echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf
- redis-server /data/node.confAdd at the end of the file: volumes:
redis_master_data:Create external configuration file: 🧰 Tools🪛 yamllint (1.35.1)[error] 81-81: trailing spaces (trailing-spaces) [error] 86-86: trailing spaces (trailing-spaces) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis-server-2: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| image: falkordb/falkordb:latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hostname: redis-server-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| container_name: redis-server-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 6381:6381 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| networks: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - redis-sentinel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| entrypoint: /bin/bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| command: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - -c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| touch /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "port 6381" >> /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "replica-announce-ip redis-server-2" >> /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "replica-announce-port 6381" >> /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "replicaof redis-server-1 6380" >> /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis-server /data/node.conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| networks: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis-sentinel: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| services: | ||
| redis-standalone: | ||
| container_name: redis-standalone | ||
| hostname: redis-standalone | ||
| image: falkordb/falkordb:latest | ||
| ports: | ||
| - 6379:6379 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -171,10 +171,13 @@ def from_url(cls, url: str, **kwargs) -> "FalkorDB": | |||||||||||||||||||||||||||||||||
| conn = redis.from_url(url, **kwargs) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| connection_kwargs = conn.connection_pool.connection_kwargs | ||||||||||||||||||||||||||||||||||
| connection_class = conn.connection_pool.connection_class | ||||||||||||||||||||||||||||||||||
| kwargs["host"] = connection_kwargs.get("host", "localhost") | ||||||||||||||||||||||||||||||||||
| kwargs["port"] = connection_kwargs.get("port", 6379) | ||||||||||||||||||||||||||||||||||
| kwargs["username"] = connection_kwargs.get("username") | ||||||||||||||||||||||||||||||||||
| kwargs["password"] = connection_kwargs.get("password") | ||||||||||||||||||||||||||||||||||
| if connection_class is redis.SSLConnection: | ||||||||||||||||||||||||||||||||||
| kwargs["ssl"] = True | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Initialize a FalkorDB instance using the updated kwargs | ||||||||||||||||||||||||||||||||||
| db = cls(**kwargs) | ||||||||||||||||||||||||||||||||||
|
|
@@ -224,7 +227,41 @@ def config_get(self, name: str) -> Union[int, str]: | |||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| return self.connection.execute_command(CONFIG_CMD, "GET", name)[1] | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| def get_replica_connections(self): | ||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||
| Retrieve a list of connections for FalkorDB replicas. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Returns: | ||||||||||||||||||||||||||||||||||
| list of tuple: A list of (hostname, port) tuples representing the | ||||||||||||||||||||||||||||||||||
| replica connections. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Raises: | ||||||||||||||||||||||||||||||||||
| ConnectionError: If unable to connect or retrieve information from | ||||||||||||||||||||||||||||||||||
| the FalkorDB setup. | ||||||||||||||||||||||||||||||||||
| ValueError: If the `mode` is neither Sentinel nor Cluster. | ||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||
| if hasattr(self, 'sentinel') and self.sentinel is not None: | ||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||
| replica_hostnames = self.sentinel.discover_slaves(service_name=self.service_name) | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace deprecated Redis terminology The - replica_hostnames = self.sentinel.discover_slaves(service_name=self.service_name)
+ replica_hostnames = self.sentinel.discover_replicas(service_name=self.service_name)📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||
| if not replica_hostnames: | ||||||||||||||||||||||||||||||||||
| raise ConnectionError("Unable to get replica hostname.") | ||||||||||||||||||||||||||||||||||
| return [(host, int(port)) for host, port in replica_hostnames] | ||||||||||||||||||||||||||||||||||
| except redis.RedisError as e: | ||||||||||||||||||||||||||||||||||
| raise ConnectionError("Failed to get replica hostnames, no hostnames found.") from e | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+244
to
+251
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Update deprecated Redis terminology and improve error handling
Apply this diff: try:
- replica_hostnames = self.sentinel.discover_slaves(service_name=self.service_name)
+ replica_hostnames = self.sentinel.discover_replicas(service_name=self.service_name)
if not replica_hostnames:
raise ConnectionError("Unable to get replica hostname.")
return [(host, int(port)) for host, port in replica_hostnames]
except redis.RedisError as e:
- raise ConnectionError("Failed to get replica hostnames, no hostnames found.") from e
+ raise ConnectionError(f"Failed to discover replicas in Sentinel mode: {str(e)}") from e📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| elif Is_Cluster(self.connection): | ||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||
| data = self.connection.get_replicas() | ||||||||||||||||||||||||||||||||||
| if not data: | ||||||||||||||||||||||||||||||||||
| raise ConnectionError("Unable to get cluster nodes") | ||||||||||||||||||||||||||||||||||
| return [ (i.host, i.port) for i in data] | ||||||||||||||||||||||||||||||||||
| except redis.RedisError as e: | ||||||||||||||||||||||||||||||||||
| raise ConnectionError("Failed to get replica hostnames") from e | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
Comment on lines
+231
to
+261
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Missing test coverage for The method requires test coverage for:
Example test structure in def test_get_replica_connections_sentinel():
# Test sentinel mode with mocked sentinel.discover_slaves
def test_get_replica_connections_cluster():
# Test cluster mode with mocked cluster_nodes
def test_get_replica_connections_errors():
# Test connection errors and invalid modes🔗 Analysis chainAdd test coverage for the new method The new Would you like me to help create comprehensive test cases covering:
🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for existing tests of the new method
fd test_.+\.py$ | xargs rg "get_replica_connections"
Length of output: 53 Script: #!/bin/bash
# Let's first check if there are any test files in the repository
fd "test.*\.py$"
# Then let's check the content of the falkordb.py file to understand the test requirements better
cat falkordb/falkordb.py
Length of output: 9548 Script: #!/bin/bash
# Let's check test_db.py as it's likely to contain tests for FalkorDB class methods
cat tests/test_db.py
# Also check if there are any mock or fixture utilities for testing
fd "conftest\.py$"
Length of output: 1366 🧰 Tools🪛 GitHub Check: codecov/patch[warning] 248-251: falkordb/falkordb.py#L248-L251 [warning] 253-258: falkordb/falkordb.py#L253-L258 [warning] 260-260: falkordb/falkordb.py#L260 🪛 Ruff251-251: Within an (B904) |
||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||
| raise ValueError(f"Unsupported Redis mode") | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| def config_set(self, name: str, value=None) -> None: | ||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||
| Update a DB level configuration. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use relative paths for compose files.
The compose file paths should be relative to the repository root.
- name: Run docker-compose for redis standalone instance uses: hoverkraft-tech/compose-action@v2.0.1 with: - compose-file: ./docker/standalone-compose.yml + compose-file: docker/standalone-compose.yml📝 Committable suggestion