Config
glide.config.GlideClientConfiguration
Bases: BaseClientConfiguration
Represents the configuration settings for a Standalone Glide client.
Attributes:
Name | Type | Description |
---|---|---|
addresses |
List[NodeAddress]
|
DNS Addresses and ports of known nodes in the cluster. |
use_tls |
bool
|
True if communication with the cluster should use Transport Level Security. |
credentials |
ServerCredentials
|
Credentials for authentication process. If none are set, the client will not authenticate itself with the server. |
read_from |
ReadFrom
|
If not set, |
request_timeout |
Optional[int]
|
The duration in milliseconds that the client should wait for a request to complete. This duration encompasses sending the request, awaiting for a response from the server, and any required reconnections or retries. If the specified timeout is exceeded for a pending request, it will result in a timeout error. If not explicitly set, a default value of 250 milliseconds will be used. |
reconnect_strategy |
Optional[BackoffStrategy]
|
Strategy used to determine how and when to reconnect, in case of connection failures. If not set, a default backoff strategy will be used. |
database_id |
Optional[int]
|
index of the logical database to connect to. |
client_name |
Optional[str]
|
Client name to be used for the client. Will be used with CLIENT SETNAME command during connection establishment. |
protocol |
ProtocolVersion
|
The version of the RESP protocol to communicate with the server. |
pubsub_subscriptions |
Optional[PubSubSubscriptions]
|
Pubsub subscriptions to be used for the client. Will be applied via SUBSCRIBE/PSUBSCRIBE commands during connection establishment. |
inflight_requests_limit |
Optional[int]
|
The maximum number of concurrent requests allowed to be in-flight (sent but not yet completed). This limit is used to control the memory usage and prevent the client from overwhelming the server or getting stuck in case of a queue backlog. If not set, a default value will be used. |
client_az |
Optional[str]
|
Availability Zone of the client. If ReadFrom strategy is AZAffinity, this setting ensures that readonly commands are directed to replicas within the specified AZ if exits. If ReadFrom strategy is AZAffinityReplicasAndPrimary, this setting ensures that readonly commands are directed to nodes (first replicas then primary) within the specified AZ if they exist. |
advanced_config |
Optional[AdvancedGlideClientConfiguration]
|
Advanced configuration settings for the client,
see |
Source code in glide/config.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
|
PubSubChannelModes
Bases: IntEnum
Describes pubsub subsciption modes. See valkey.io for more details
Source code in glide/config.py
372 373 374 375 376 377 378 379 380 381 |
|
Exact = 0
class-attribute
instance-attribute
Use exact channel names
Pattern = 1
class-attribute
instance-attribute
Use channel name patterns
PubSubSubscriptions
dataclass
Describes pubsub configuration for standalone mode client.
Attributes:
Name | Type | Description |
---|---|---|
channels_and_patterns |
Dict[PubSubChannelModes, Set[str]]
|
Channels and patterns by modes. |
callback |
Optional[Callable[[PubSubMsg, Any], None]]
|
Optional callback to accept the incomming messages. |
context |
Any
|
Arbitrary context to pass to the callback. |
Source code in glide/config.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
|
glide.config.GlideClusterClientConfiguration
Bases: BaseClientConfiguration
Represents the configuration settings for a Cluster Glide client.
Attributes:
Name | Type | Description |
---|---|---|
addresses |
List[NodeAddress]
|
DNS Addresses and ports of known nodes in the cluster. The list can be partial, as the client will attempt to map out the cluster and find all nodes. For example::
|
use_tls |
bool
|
True if communication with the cluster should use Transport Level Security. |
credentials |
ServerCredentials
|
Credentials for authentication process. If none are set, the client will not authenticate itself with the server. |
read_from |
ReadFrom
|
If not set, |
request_timeout |
Optional[int]
|
The duration in milliseconds that the client should wait for a request to complete. This duration encompasses sending the request, awaiting for a response from the server, and any required reconnections or retries. If the specified timeout is exceeded for a pending request, it will result in a timeout error. If not explicitly set, a default value of 250 milliseconds will be used. |
reconnect_strategy |
Optional[BackoffStrategy]
|
Strategy used to determine how and when to reconnect, in case of connection failures. If not set, a default backoff strategy will be used. |
client_name |
Optional[str]
|
Client name to be used for the client. Will be used with CLIENT SETNAME command during connection establishment. |
protocol |
ProtocolVersion
|
The version of the RESP protocol to communicate with the server. |
periodic_checks |
Union[PeriodicChecksStatus, PeriodicChecksManualInterval]
|
Configure the periodic topology checks. These checks evaluate changes in the cluster's topology, triggering a slot refresh when detected. Periodic checks ensure a quick and efficient process by querying a limited number of nodes. Defaults to PeriodicChecksStatus.ENABLED_DEFAULT_CONFIGS. |
pubsub_subscriptions |
Optional[PubSubSubscriptions]
|
Pubsub subscriptions to be used for the client. Will be applied via SUBSCRIBE/PSUBSCRIBE/SSUBSCRIBE commands during connection establishment. |
inflight_requests_limit |
Optional[int]
|
The maximum number of concurrent requests allowed to be in-flight (sent but not yet completed). This limit is used to control the memory usage and prevent the client from overwhelming the server or getting stuck in case of a queue backlog. If not set, a default value will be used. |
client_az |
Optional[str]
|
Availability Zone of the client. If ReadFrom strategy is AZAffinity, this setting ensures that readonly commands are directed to replicas within the specified AZ if exits. If ReadFrom strategy is AZAffinityReplicasAndPrimary, this setting ensures that readonly commands are directed to nodes (first replicas then primary) within the specified AZ if they exist. |
advanced_config |
Optional[AdvancedGlideClusterClientConfiguration])
|
Advanced configuration settings for the client,
see |
Note
Currently, the reconnection strategy in cluster mode is not configurable, and exponential backoff with fixed values is used.
Source code in glide/config.py
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 |
|
PubSubChannelModes
Bases: IntEnum
Describes pubsub subsciption modes. See valkey.io for more details
Source code in glide/config.py
540 541 542 543 544 545 546 547 548 549 550 551 |
|
Exact = 0
class-attribute
instance-attribute
Use exact channel names
Pattern = 1
class-attribute
instance-attribute
Use channel name patterns
Sharded = 2
class-attribute
instance-attribute
Use sharded pubsub. Available since Valkey version 7.0.
PubSubSubscriptions
dataclass
Describes pubsub configuration for cluster mode client.
Attributes:
Name | Type | Description |
---|---|---|
channels_and_patterns |
Dict[PubSubChannelModes, Set[str]]
|
Channels and patterns by modes. |
callback |
Optional[Callable[[PubSubMsg, Any], None]]
|
Optional callback to accept the incoming messages. |
context |
Any
|
Arbitrary context to pass to the callback. |
Source code in glide/config.py
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 |
|
glide.config.NodeAddress
Represents the address and port of a node in the cluster.
Attributes:
Name | Type | Description |
---|---|---|
host |
str
|
The server host. Defaults to "localhost". |
port |
int
|
The server port. Defaults to 6379. |
Source code in glide/config.py
17 18 19 20 21 22 23 24 25 26 27 28 |
|
glide.config.ReadFrom
Bases: Enum
Represents the client's read from strategy.
Source code in glide/config.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
AZ_AFFINITY = ProtobufReadFrom.AZAffinity
class-attribute
instance-attribute
Spread the read requests between replicas in the same client's AZ (Aviliablity zone) in a round robin manner, falling back to other replicas or the primary if needed
AZ_AFFINITY_REPLICAS_AND_PRIMARY = ProtobufReadFrom.AZAffinityReplicasAndPrimary
class-attribute
instance-attribute
Spread the read requests among nodes within the client's Availability Zone (AZ) in a round robin manner, prioritizing local replicas, then the local primary, and falling back to any replica or the primary if needed.
PREFER_REPLICA = ProtobufReadFrom.PreferReplica
class-attribute
instance-attribute
Spread the requests between all replicas in a round robin manner. If no replica is available, route the requests to the primary.
PRIMARY = ProtobufReadFrom.Primary
class-attribute
instance-attribute
Always get from primary, in order to get the freshest data.
glide.config.ProtocolVersion
Bases: Enum
Represents the communication protocol with the server.
Source code in glide/config.py
57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
RESP2 = SentProtocolVersion.RESP2
class-attribute
instance-attribute
Communicate using RESP2.
RESP3 = SentProtocolVersion.RESP3
class-attribute
instance-attribute
Communicate using RESP3.
glide.config.BackoffStrategy
Represents the strategy used to determine how and when to reconnect, in case of connection failures. The time between attempts grows exponentially, to the formula rand(0 .. factor * (exponentBase ^ N)), where N is the number of failed attempts. Once the maximum value is reached, that will remain the time between retry attempts until a reconnect attempt is successful. The client will attempt to reconnect indefinitely.
Attributes:
Name | Type | Description |
---|---|---|
num_of_retries |
int
|
Number of retry attempts that the client should perform when disconnected from the server, where the time between retries increases. Once the retries have reached the maximum value, the time between retries will remain constant until a reconnect attempt is succesful. |
factor |
int
|
The multiplier that will be applied to the waiting time between each retry. |
exponent_base |
int
|
The exponent base configured for the strategy. |
jitter_percent |
Optional[int]
|
The Jitter percent on the calculated duration. If not set, a default value will be used. |
Source code in glide/config.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
glide.config.ServerCredentials
Represents the credentials for connecting to a server.
Attributes:
Name | Type | Description |
---|---|---|
password |
str
|
The password that will be used for authenticating connections to the servers. |
username |
Optional[str]
|
The username that will be used for authenticating connections to the servers. If not supplied, "default" will be used. |
Source code in glide/config.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
glide.config.PeriodicChecksManualInterval
Represents a manually configured interval for periodic checks.
Attributes:
Name | Type | Description |
---|---|---|
duration_in_sec |
int
|
The duration in seconds for the interval between periodic checks. |
Source code in glide/config.py
122 123 124 125 126 127 128 129 130 131 |
|
glide.config.PeriodicChecksStatus
Bases: Enum
Represents the cluster's periodic checks status. To configure specific interval, see PeriodicChecksManualInterval.
Source code in glide/config.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
DISABLED = 1
class-attribute
instance-attribute
Disables the periodic checks.
ENABLED_DEFAULT_CONFIGS = 0
class-attribute
instance-attribute
Enables the periodic checks with the default configurations.
glide.config.BaseClientConfiguration
Represents the configuration settings for a Glide client.
Attributes:
Name | Type | Description |
---|---|---|
addresses |
List[NodeAddress]
|
DNS Addresses and ports of known nodes in the cluster. If the server is in cluster mode the list can be partial, as the client will attempt to map out the cluster and find all nodes. If the server is in standalone mode, only nodes whose addresses were provided will be used by the client. For example::
|
use_tls |
bool
|
True if communication with the cluster should use Transport Level Security. Should match the TLS configuration of the server/cluster, otherwise the connection attempt will fail |
credentials |
ServerCredentials
|
Credentials for authentication process. If none are set, the client will not authenticate itself with the server. |
read_from |
ReadFrom
|
If not set, |
request_timeout |
Optional[int]
|
The duration in milliseconds that the client should wait for a request to complete. This duration encompasses sending the request, awaiting for a response from the server, and any required reconnections or retries. If the specified timeout is exceeded for a pending request, it will result in a timeout error. If not explicitly set, a default value of 250 milliseconds will be used. |
reconnect_strategy |
Optional[BackoffStrategy]
|
Strategy used to determine how and when to reconnect, in case of connection failures. If not set, a default backoff strategy will be used. |
client_name |
Optional[str]
|
Client name to be used for the client. Will be used with CLIENT SETNAME command during connection establishment. |
protocol |
ProtocolVersion
|
Serialization protocol to be used. If not set, |
inflight_requests_limit |
Optional[int]
|
The maximum number of concurrent requests allowed to be in-flight (sent but not yet completed). This limit is used to control the memory usage and prevent the client from overwhelming the server or getting stuck in case of a queue backlog. If not set, a default value will be used. |
client_az |
Optional[str]
|
Availability Zone of the client. If ReadFrom strategy is AZAffinity, this setting ensures that readonly commands are directed to replicas within the specified AZ if exits. If ReadFrom strategy is AZAffinityReplicasAndPrimary, this setting ensures that readonly commands are directed to nodes (first replicas then primary) within the specified AZ if they exist. |
advanced_config |
Optional[AdvancedBaseClientConfiguration]
|
Advanced configuration settings for the client. |
Source code in glide/config.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
|