-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add support for CLIENT SETINFO
#2857
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
Changes from all commits
c22ede8
b25b0a3
b5f691e
8f3787c
31aaadb
416645c
ea899b8
c73673b
c288f40
7cac884
55525a2
c2e145e
9b2f4b7
ef17c7c
7994738
76ff803
f5e1bc6
23659b4
aa0d5c8
fd847bb
98feba9
87adecf
77cef76
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 |
---|---|---|
|
@@ -15,7 +15,12 @@ exclude = | |
whitelist.py, | ||
tasks.py | ||
ignore = | ||
E126 | ||
E203 | ||
F405 | ||
N801 | ||
N802 | ||
N803 | ||
N806 | ||
N815 | ||
W503 | ||
E203 | ||
E126 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
HIREDIS_AVAILABLE, | ||
HIREDIS_PACK_AVAILABLE, | ||
SSL_AVAILABLE, | ||
get_lib_version, | ||
str_if_bytes, | ||
) | ||
|
||
|
@@ -140,6 +141,8 @@ def __init__( | |
socket_read_size=65536, | ||
health_check_interval=0, | ||
client_name=None, | ||
lib_name="redis-py", | ||
lib_version=get_lib_version(), | ||
username=None, | ||
retry=None, | ||
redis_connect_func=None, | ||
|
@@ -164,6 +167,8 @@ def __init__( | |
self.pid = os.getpid() | ||
self.db = db | ||
self.client_name = client_name | ||
self.lib_name = lib_name | ||
self.lib_version = lib_version | ||
self.credential_provider = credential_provider | ||
self.password = password | ||
self.username = username | ||
|
@@ -360,6 +365,21 @@ def on_connect(self): | |
if str_if_bytes(self.read_response()) != "OK": | ||
raise ConnectionError("Error setting client name") | ||
|
||
try: | ||
# set the library name and version | ||
if self.lib_name: | ||
self.send_command("CLIENT", "SETINFO", "LIB-NAME", self.lib_name) | ||
self.read_response() | ||
except ResponseError: | ||
pass | ||
|
||
try: | ||
if self.lib_version: | ||
self.send_command("CLIENT", "SETINFO", "LIB-VER", self.lib_version) | ||
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. Pipeline SETINFO and SELECT same as in the async suggestion above. 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. Specifically not sent because of the interface - but a suggestion we'd debated previously. At this level, the pipeline shouldn't be used (yet). IMHO once reorganizing connections, all items for connect should be pipelined, agreed. 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. Well, you probably debated it out of band, not in this PR :) What "interface" are you speaking of? A pipeline isn't an object "to be used", it is just a way of sending a bunch of commands and not waiting for each individual response before sending the next command. It is always supported by the server. |
||
self.read_response() | ||
except ResponseError: | ||
pass | ||
|
||
# if a database is specified, switch to it | ||
if self.db: | ||
self.send_command("SELECT", self.db) | ||
|
Uh oh!
There was an error while loading. Please reload this page.