Skip to content
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

Creds provider #16

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
86da7ff
A CredentialsProvider class has been added to allow the user to add h…
barshaul Jul 5, 2022
5dfddde
Moved CredentialsProvider to a separate file, added type hints
barshaul Jul 18, 2022
243b244
Changed username and password to properties
barshaul Aug 9, 2022
af8e560
Added: StaticCredentialProvider, examples, tests
barshaul Aug 23, 2022
2261cb0
Changed private members' prefix to __
barshaul Aug 30, 2022
ddfe1ea
fixed linters
barshaul Sep 1, 2022
b481067
fixed auth test
barshaul Sep 4, 2022
686d172
fixed credential test
barshaul Sep 4, 2022
d1d10af
Raise an error if username or password are passed along with credenti…
barshaul Sep 20, 2022
9de8d21
fixing linters
barshaul Sep 20, 2022
def996b
fixing test
barshaul Sep 21, 2022
29c8006
Changed dundered to single per side underscore
barshaul Oct 2, 2022
6b8cf1f
Changed Connection class members username and password to properties …
barshaul Oct 2, 2022
c37e0f1
Reverting last commit and adding backward compatibility to 'username'…
barshaul Oct 3, 2022
abe6137
Refactored CredentialProvider class
barshaul Nov 2, 2022
6303243
Fixing tuple type to Tuple
barshaul Nov 2, 2022
057ed82
Fixing optional string members in UsernamePasswordCredentialProvider
barshaul Nov 2, 2022
ba91b0f
Fixed credential test
barshaul Nov 2, 2022
6223901
Added credential provider support to AsyncRedis
barshaul Nov 9, 2022
fac8333
Merge branch 'master' into creds_provider
dvora-h Nov 10, 2022
b951e19
linters
dvora-h Nov 10, 2022
72c366d
linters
dvora-h Nov 10, 2022
4b35cb2
linters
dvora-h Nov 10, 2022
4c82551
linters - black
dvora-h Nov 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* ClusterPipeline Doesn't Handle ConnectionError for Dead Hosts (#2225)
* Remove compatibility code for old versions of Hiredis, drop Packaging dependency
* The `deprecated` library is no longer a dependency
* Added CredentialsProvider class to support password rotation
* Enable Lock for asyncio cluster mode

* 4.1.3 (Feb 8, 2022)
Expand Down
129 changes: 76 additions & 53 deletions docs/examples/asyncio_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -41,27 +36,29 @@
"connection = redis.Redis()\n",
"print(f\"Ping successful: {await connection.ping()}\")\n",
"await connection.close()"
]
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"If you supply a custom `ConnectionPool` that is supplied to several `Redis` instances, you may want to disconnect the connection pool explicitly. Disconnecting the connection pool simply disconnects all connections hosted in the pool."
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"If you supply a custom `ConnectionPool` that is supplied to several `Redis` instances, you may want to disconnect the connection pool explicitly. Disconnecting the connection pool simply disconnects all connections hosted in the pool."
]
}
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import redis.asyncio as redis\n",
Expand All @@ -70,15 +67,16 @@
"await connection.close()\n",
"# Or: await connection.close(close_connection_pool=False)\n",
"await connection.connection_pool.disconnect()"
]
},
{
"cell_type": "markdown",
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
"name": "#%%\n"
}
},
}
},
{
"cell_type": "markdown",
"source": [
"## Transactions (Multi/Exec)\n",
"\n",
Expand All @@ -87,16 +85,17 @@
"The commands will not be reflected in Redis until execute() is called & awaited.\n",
"\n",
"Usually, when performing a bulk operation, taking advantage of a “transaction” (e.g., Multi/Exec) is to be desired, as it will also add a layer of atomicity to your bulk operation."
]
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import redis.asyncio as redis\n",
Expand All @@ -106,25 +105,31 @@
" ok1, ok2 = await (pipe.set(\"key1\", \"value1\").set(\"key2\", \"value2\").execute())\n",
"assert ok1\n",
"assert ok2"
]
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Pub/Sub Mode\n",
"\n",
"Subscribing to specific channels:"
]
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -165,23 +170,29 @@
" await r.publish(\"channel:1\", STOPWORD)\n",
"\n",
" await future"
]
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Subscribing to channels matching a glob-style pattern:"
]
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -223,11 +234,16 @@
" await r.publish(\"channel:1\", STOPWORD)\n",
"\n",
" await future"
]
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sentinel Client\n",
"\n",
Expand All @@ -236,16 +252,17 @@
"Calling aioredis.sentinel.Sentinel.master_for or aioredis.sentinel.Sentinel.slave_for methods will return Redis clients connected to specified services monitored by Sentinel.\n",
"\n",
"Sentinel client will detect failover and reconnect Redis clients automatically."
]
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import asyncio\n",
Expand All @@ -260,7 +277,13 @@
"assert ok\n",
"val = await r.get(\"key\")\n",
"assert val == b\"value\""
]
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
}
],
"metadata": {
Expand All @@ -284,4 +307,4 @@
},
"nbformat": 4,
"nbformat_minor": 1
}
}
Loading