glide_sync
GlideClient
Bases: BaseClient, StandaloneCommands
Client used for connection to standalone servers. For full documentation, see https://glide.valkey.io/how-to/client-initialization/#standalone
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/glide_client.py
1082 1083 1084 1085 1086 1087 | |
GlideClusterClient
Bases: BaseClient, ClusterCommands
Client used for connection to cluster servers. For full documentation, see https://glide.valkey.io/how-to/client-initialization/#cluster
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/glide_client.py
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | |
Logger
A singleton class that allows logging which is consistent with logs from the internal GLIDE core. The logger can be set up in 2 ways - 1. By calling Logger.init, which configures the logger only if it wasn't previously configured. 2. By calling Logger.set_logger_config, which replaces the existing configuration, and means that new logs will not be saved with the logs that were sent before the call. If none of these functions are called, the first log attempt will initialize a new logger with default configuration.
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/logger.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
init(level=None, file_name=None)
classmethod
Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to
replace an existing logger. Otherwise, use set_logger_config for overriding the existing logger configs.
The logger will filter all logs with a level lower than the given level.
If given a file_name argument, will write the logs to files postfixed with file_name. If file_name isn't provided,
the logs will be written to the console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
Optional[Level]
|
Set the logger level to one of [ERROR, WARN, INFO, DEBUG, TRACE, OFF]. If log level isn't provided, the logger will be configured with default configuration. To turn off logging completely, set the level to Level.OFF. |
None
|
file_name
|
Optional[str]
|
If provided the target of the logs will be the file mentioned. Otherwise, logs will be printed to the console. |
None
|
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/logger.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
log(log_level, log_identifier, message, err=None)
classmethod
Logs the provided message if the provided log level is lower then the logger level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_level
|
Level
|
The log level of the provided message. |
required |
log_identifier
|
str
|
The log identifier should give the log a context. |
required |
message
|
str
|
The message to log. |
required |
err
|
Optional[Exception]
|
The exception or error to log. |
None
|
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/logger.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
set_logger_config(level=None, file_name=None)
classmethod
Creates a new logger instance and configure it with the provided log level and file name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
Optional[Level]
|
Set the logger level to one of [ERROR, WARN, INFO, DEBUG, TRACE, OFF]. If log level isn't provided, the logger will be configured with default configuration. To turn off logging completely, set the level to OFF. |
None
|
file_name
|
Optional[str]
|
If provided the target of the logs will be the file mentioned. Otherwise, logs will be printed to the console. |
None
|
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/logger.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
OpenTelemetry
Singleton class for managing OpenTelemetry configuration and operations.
This class provides a centralized way to initialize OpenTelemetry and control sampling behavior at runtime.
Example usage
from glide_sync import OpenTelemetry, OpenTelemetryConfig, OpenTelemetryTracesConfig, OpenTelemetryMetricsConfig
OpenTelemetry.init(OpenTelemetryConfig(
traces=OpenTelemetryTracesConfig(
endpoint="http://localhost:4318/v1/traces",
sample_percentage=10 # Optional, defaults to 1. Can also be changed at runtime via set_sample_percentage().
),
metrics=OpenTelemetryMetricsConfig(
endpoint="http://localhost:4318/v1/metrics"
),
flush_interval_ms=1000 # Optional, defaults to 5000
))
Note
OpenTelemetry can only be initialized once per process. Subsequent calls to init() will be ignored. This is by design, as OpenTelemetry is a global resource that should be configured once at application startup.
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/opentelemetry.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
init(config)
classmethod
Initialize the OpenTelemetry instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
OpenTelemetryConfig
|
The OpenTelemetry configuration |
required |
Note
OpenTelemetry can only be initialized once per process. Subsequent calls will be ignored and a warning will be logged.
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/opentelemetry.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
is_initialized()
classmethod
Check if the OpenTelemetry instance is initialized.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the OpenTelemetry instance is initialized, False otherwise |
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/opentelemetry.py
125 126 127 128 129 130 131 132 133 | |
get_sample_percentage()
classmethod
Get the sample percentage for traces.
Returns:
| Type | Description |
|---|---|
Optional[int]
|
Optional[int]: The sample percentage for traces only if OpenTelemetry is initialized and the traces config is set, otherwise None. |
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/opentelemetry.py
135 136 137 138 139 140 141 142 143 144 145 146 | |
should_sample()
classmethod
Determines if the current request should be sampled for OpenTelemetry tracing. Uses the configured sample percentage to randomly decide whether to create a span for this request.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the request should be sampled, False otherwise |
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/opentelemetry.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
set_sample_percentage(percentage)
classmethod
Set the percentage of requests to be sampled and traced. Must be a value between 0 and 100. This setting only affects traces, not metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
percentage
|
int
|
The sample percentage 0-100 |
required |
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
If OpenTelemetry is not initialized or traces config is not set |
Remarks
This method can be called at runtime to change the sampling percentage without reinitializing OpenTelemetry.
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/opentelemetry.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
ClusterScanCursor
Represents a cursor for cluster scan operations.
This class manages the state of a cluster scan cursor and automatically cleans up resources when the cursor is no longer needed.
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/sync_commands/cluster_scan_cursor.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
get_cursor()
Get the current cursor string.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The current cursor string |
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/sync_commands/cluster_scan_cursor.py
35 36 37 38 39 40 41 42 | |
is_finished()
Check if the cluster scan is finished.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the scan is finished, False otherwise |
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/sync_commands/cluster_scan_cursor.py
44 45 46 47 48 49 50 51 | |
Script
A wrapper for a Script object for the invoke script function. As long as
this object is alive, the script's code is saved in memory, and can be resent to the server.
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/sync_commands/script.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
get_hash()
Get the SHA1 hash of the script.
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/sync_commands/script.py
61 62 63 64 65 | |
get_min_compressed_size()
Get the minimum compression size in bytes.
Returns the minimum size threshold for compression. Values smaller than this will not be compressed.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The minimum compression size in bytes (currently 6 bytes: 5-byte header + 1 byte data) |
Source code in doc-gen/valkey-glide/python/glide-sync/glide_sync/sync_commands/utils.py
6 7 8 9 10 11 12 13 14 15 16 17 | |