Skip to content

Commit 58af10f

Browse files
authored
Merge branch 'master' into add-return-type-annotations
2 parents 2283933 + ce59a2c commit 58af10f

20 files changed

+754
-147
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### Description of change
2+
3+
_Please provide a description of the change here._
4+
15
### Pull Request check-list
26

37
_Please make sure to review and check all of these items:_
@@ -10,7 +14,3 @@ _Please make sure to review and check all of these items:_
1014

1115
_NOTE: these things are not required to open a PR and can be done
1216
afterwards / while the PR is open._
13-
14-
### Description of change
15-
16-
_Please provide a description of the change here._

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
steps:
3838
- name: Checkout repository
39-
uses: actions/checkout@v5
39+
uses: actions/checkout@v6
4040

4141
# Initializes the CodeQL tools for scanning.
4242
- name: Initialize CodeQL

.github/workflows/docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
name: Build docs
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v5
28+
- uses: actions/checkout@v6
2929
- uses: actions/setup-python@v6
3030
with:
3131
python-version: "3.10"

.github/workflows/hiredis-py-integration.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ env:
2323
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2424
# this speeds up coverage with Python 3.12: https://github.com/nedbat/coveragepy/issues/1665
2525
COVERAGE_CORE: sysmon
26-
CURRENT_CLIENT_LIBS_TEST_STACK_IMAGE_TAG: '8.0.2'
27-
CURRENT_REDIS_VERSION: '8.0.2'
26+
CURRENT_CLIENT_LIBS_TEST_STACK_IMAGE_TAG: '8.4.0'
27+
CURRENT_REDIS_VERSION: '8.4.0'
2828

2929
jobs:
3030
redis_version:
@@ -53,7 +53,7 @@ jobs:
5353
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
5454
name: Redis ${{ matrix.redis-version }}; Python ${{ matrix.python-version }}; RESP Parser:${{matrix.parser-backend}} (${{ matrix.hiredis-version }}); EL:${{matrix.event-loop}}
5555
steps:
56-
- uses: actions/checkout@v5
56+
- uses: actions/checkout@v6
5757
with:
5858
ref: ${{ inputs.redis-py-branch }}
5959
- name: Run tests

.github/workflows/integration.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ env:
2929
COVERAGE_CORE: sysmon
3030
# patch releases get included in the base version image when they are published
3131
# for example after 8.2.1 is published, 8.2 image contains 8.2.1 content
32-
CURRENT_CLIENT_LIBS_TEST_STACK_IMAGE_TAG: '8.2'
33-
CURRENT_REDIS_VERSION: '8.2'
32+
CURRENT_CLIENT_LIBS_TEST_STACK_IMAGE_TAG: '8.4.0'
33+
CURRENT_REDIS_VERSION: '8.4.0'
3434

3535
jobs:
3636
dependency-audit:
3737
name: Dependency audit
3838
runs-on: ubuntu-latest
3939
steps:
40-
- uses: actions/checkout@v5
40+
- uses: actions/checkout@v6
4141
- uses: pypa/gh-action-pip-audit@v1.0.8
4242
with:
4343
inputs: dev_requirements.txt
@@ -48,7 +48,7 @@ jobs:
4848
name: Code linters
4949
runs-on: ubuntu-latest
5050
steps:
51-
- uses: actions/checkout@v5
51+
- uses: actions/checkout@v6
5252
- uses: actions/setup-python@v6
5353
with:
5454
python-version: "3.10"
@@ -76,15 +76,15 @@ jobs:
7676
max-parallel: 15
7777
fail-fast: false
7878
matrix:
79-
redis-version: ['8.4-GA-pre.2', '${{ needs.redis_version.outputs.CURRENT }}', '8.0.2' ,'7.4.4', '7.2.9']
79+
redis-version: ['${{ needs.redis_version.outputs.CURRENT }}', '8.2', '8.0.2' ,'7.4.4', '7.2.9']
8080
python-version: ['3.10', '3.14']
8181
parser-backend: ['plain']
8282
event-loop: ['asyncio']
8383
env:
8484
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
8585
name: Redis ${{ matrix.redis-version }}; Python ${{ matrix.python-version }}; RESP Parser:${{matrix.parser-backend}}; EL:${{matrix.event-loop}}
8686
steps:
87-
- uses: actions/checkout@v5
87+
- uses: actions/checkout@v6
8888
- name: Run tests
8989
uses: ./.github/actions/run-tests
9090
with:
@@ -108,7 +108,7 @@ jobs:
108108
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
109109
name: Redis ${{ matrix.redis-version }}; Python ${{ matrix.python-version }}; RESP Parser:${{matrix.parser-backend}}; EL:${{matrix.event-loop}}
110110
steps:
111-
- uses: actions/checkout@v5
111+
- uses: actions/checkout@v6
112112
- name: Run tests
113113
uses: ./.github/actions/run-tests
114114
with:
@@ -133,7 +133,7 @@ jobs:
133133
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
134134
name: Redis ${{ matrix.redis-version }}; Python ${{ matrix.python-version }}; RESP Parser:${{matrix.parser-backend}} (${{ matrix.hiredis-version }}); EL:${{matrix.event-loop}}
135135
steps:
136-
- uses: actions/checkout@v5
136+
- uses: actions/checkout@v6
137137
- name: Run tests
138138
uses: ./.github/actions/run-tests
139139
with:
@@ -158,7 +158,7 @@ jobs:
158158
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
159159
name: Redis ${{ matrix.redis-version }}; Python ${{ matrix.python-version }}; RESP Parser:${{matrix.parser-backend}}; EL:${{matrix.event-loop}}
160160
steps:
161-
- uses: actions/checkout@v5
161+
- uses: actions/checkout@v6
162162
- name: Run tests
163163
uses: ./.github/actions/run-tests
164164
with:
@@ -176,7 +176,7 @@ jobs:
176176
matrix:
177177
extension: ['tar.gz', 'whl']
178178
steps:
179-
- uses: actions/checkout@v5
179+
- uses: actions/checkout@v6
180180
- uses: actions/setup-python@v6
181181
with:
182182
python-version: "3.10"
@@ -195,7 +195,7 @@ jobs:
195195
matrix:
196196
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', 'pypy-3.10', 'pypy-3.11']
197197
steps:
198-
- uses: actions/checkout@v5
198+
- uses: actions/checkout@v6
199199
- uses: actions/setup-python@v6
200200
with:
201201
python-version: ${{ matrix.python-version }}

.github/workflows/pypi-publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
build_and_package:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v5
16+
- uses: actions/checkout@v6
1717
- name: install python
1818
uses: actions/setup-python@v6
1919
with:

.github/workflows/spellcheck.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- name: Checkout
9-
uses: actions/checkout@v5
9+
uses: actions/checkout@v6
1010
- name: Check Spelling
11-
uses: rojopolis/spellcheck-github-actions@0.53.0
11+
uses: rojopolis/spellcheck-github-actions@0.55.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
# image tag 8.0-RC2-pre is the one matching the 8.0 GA release
33
x-client-libs-stack-image: &client-libs-stack-image
4-
image: "redislabs/client-libs-test:${CLIENT_LIBS_TEST_STACK_IMAGE_TAG:-8.4-RC1-pre.2}"
4+
image: "redislabs/client-libs-test:${CLIENT_LIBS_TEST_STACK_IMAGE_TAG:-8.4.0}"
55

66
x-client-libs-image: &client-libs-image
7-
image: "redislabs/client-libs-test:${CLIENT_LIBS_TEST_IMAGE_TAG:-8.4-RC1-pre.2}"
7+
image: "redislabs/client-libs-test:${CLIENT_LIBS_TEST_IMAGE_TAG:-8.4.0}"
88

99
services:
1010

docs/multi_database.rst

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ reverse proxy behind an actual REST API endpoint.
315315
health_check_url="https://cluster.example.com",
316316
),
317317
],
318-
# Add custom checks (in addition to default PingHealthCheck)
318+
# Add custom health check to replace the default
319319
health_checks=[
320320
# Redis Enterprise REST-based lag-aware check
321321
LagAwareHealthCheck(
@@ -412,6 +412,51 @@ To enable periodic fallback to a higher-priority healthy database, set `auto_fal
412412
)
413413
client = MultiDBClient(cfg)
414414
415+
416+
Custom failover callbacks
417+
-------------------------
418+
419+
You may want to activate custom actions when failover happens. For example, you may want to collect some metrics,
420+
logs or externally persist a connection state.
421+
422+
You can register your own event listener for the `ActiveDatabaseChanged` event (which is emitted when a failover happens) using
423+
the `EventDispatcher`.
424+
425+
.. code-block:: python
426+
427+
class LogFailoverEventListener(EventListenerInterface):
428+
def __init__(self, logger: Logger):
429+
self.logger = logger
430+
431+
def listen(self, event: ActiveDatabaseChanged):
432+
self.logger.warning(
433+
f"Failover happened. Active database switched from {event.old_database} to {event.new_database}"
434+
)
435+
436+
event_dispatcher = EventDispatcher()
437+
listener = LogFailoverEventListener(logging.getLogger(__name__))
438+
439+
# Register custom listener
440+
event_dispatcher.register_listeners(
441+
{
442+
ActiveDatabaseChanged: [listener],
443+
}
444+
)
445+
446+
config = MultiDbConfig(
447+
client_class=client_class,
448+
databases_config=db_configs,
449+
command_retry=command_retry,
450+
min_num_failures=min_num_failures,
451+
health_check_probes=3,
452+
health_check_interval=health_check_interval,
453+
event_dispatcher=event_dispatcher,
454+
health_check_probes_delay=health_check_delay,
455+
)
456+
457+
client = MultiDBClient(config)
458+
459+
415460
Managing databases at runtime
416461
-----------------------------
417462

redis/asyncio/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ class Redis(
126126

127127
@classmethod
128128
def from_url(
129-
cls: type[_RedisT],
129+
cls: Type["Redis"],
130130
url: str,
131131
single_connection_client: bool = False,
132132
auto_close_connection_pool: Optional[bool] = None,
133133
**kwargs,
134-
) -> _RedisT:
134+
) -> "Redis":
135135
"""
136136
Return a Redis client object configured from the given URL
137137

0 commit comments

Comments
 (0)