@@ -83,6 +83,7 @@ def __init__(
83
83
credentials : Optional [RedisCredentials ] = None ,
84
84
read_from : ReadFrom = ReadFrom .PRIMARY ,
85
85
request_timeout : Optional [int ] = None ,
86
+ client_name : Optional [str ] = None ,
86
87
):
87
88
"""
88
89
Represents the configuration settings for a Redis client.
@@ -106,12 +107,14 @@ def __init__(
106
107
request_timeout (Optional[int]): The duration in milliseconds that the client should wait for a request to complete.
107
108
This duration encompasses sending the request, awaiting for a response from the server, and any required reconnections or retries.
108
109
If the specified timeout is exceeded for a pending request, it will result in a timeout error. If not set, a default value will be used.
110
+ client_name (Optional[str]): Client name to be used for the client. Will be used with CLIENT SETNAME command during connection establishment.
109
111
"""
110
112
self .addresses = addresses or [NodeAddress ()]
111
113
self .use_tls = use_tls
112
114
self .credentials = credentials
113
115
self .read_from = read_from
114
116
self .request_timeout = request_timeout
117
+ self .client_name = client_name
115
118
116
119
def _create_a_protobuf_conn_request (
117
120
self , cluster_mode : bool = False
@@ -139,6 +142,8 @@ def _create_a_protobuf_conn_request(
139
142
if self .credentials .username :
140
143
request .authentication_info .username = self .credentials .username
141
144
request .authentication_info .password = self .credentials .password
145
+ if self .client_name :
146
+ request .client_name = self .client_name
142
147
request .protocol = SentProtocolVersion .RESP2
143
148
144
149
return request
@@ -169,6 +174,7 @@ class RedisClientConfiguration(BaseClientConfiguration):
169
174
connection failures.
170
175
If not set, a default backoff strategy will be used.
171
176
database_id (Optional[Int]): index of the logical database to connect to.
177
+ client_name (Optional[str]): Client name to be used for the client. Will be used with CLIENT SETNAME command during connection establishment.
172
178
"""
173
179
174
180
def __init__ (
@@ -180,13 +186,15 @@ def __init__(
180
186
request_timeout : Optional [int ] = None ,
181
187
reconnect_strategy : Optional [BackoffStrategy ] = None ,
182
188
database_id : Optional [int ] = None ,
189
+ client_name : Optional [str ] = None ,
183
190
):
184
191
super ().__init__ (
185
192
addresses = addresses ,
186
193
use_tls = use_tls ,
187
194
credentials = credentials ,
188
195
read_from = read_from ,
189
196
request_timeout = request_timeout ,
197
+ client_name = client_name ,
190
198
)
191
199
self .reconnect_strategy = reconnect_strategy
192
200
self .database_id = database_id
@@ -229,6 +237,7 @@ class ClusterClientConfiguration(BaseClientConfiguration):
229
237
request_timeout (Optional[int]): The duration in milliseconds that the client should wait for a request to complete.
230
238
This duration encompasses sending the request, awaiting for a response from the server, and any required reconnections or retries.
231
239
If the specified timeout is exceeded for a pending request, it will result in a timeout error. If not set, a default value will be used.
240
+ client_name (Optional[str]): Client name to be used for the client. Will be used with CLIENT SETNAME command during connection establishment.
232
241
233
242
Notes:
234
243
Currently, the reconnection strategy in cluster mode is not configurable, and exponential backoff
@@ -242,11 +251,13 @@ def __init__(
242
251
credentials : Optional [RedisCredentials ] = None ,
243
252
read_from : ReadFrom = ReadFrom .PRIMARY ,
244
253
request_timeout : Optional [int ] = None ,
254
+ client_name : Optional [str ] = None ,
245
255
):
246
256
super ().__init__ (
247
257
addresses = addresses ,
248
258
use_tls = use_tls ,
249
259
credentials = credentials ,
250
260
read_from = read_from ,
251
261
request_timeout = request_timeout ,
262
+ client_name = client_name ,
252
263
)
0 commit comments