glide_shared.ffi_helpers
Shared FFI helper utilities for converting Python arguments to C-compatible arrays.
FFIClientTypeEnum
Client type enum matching the Rust ClientType repr.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
138 139 140 141 142 | |
encode_arg(arg)
Encode a single argument to bytes.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
12 13 14 15 16 17 18 | |
to_c_strings(ffi, args)
Convert Python arguments to C-compatible (pointers_array, lengths_array, buffers).
The returned buffers list must be kept alive for the duration of the FFI call.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
21 22 23 24 25 26 27 28 29 30 31 | |
to_c_route_ptr_and_len(ffi, route)
Convert a Route to C-compatible (route_ptr, route_len, route_bytes).
The returned route_bytes must be kept alive for the duration of the FFI call.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
to_c_route_info(ffi, route)
Convert a Route to a C RouteInfo* for batch operations.
Returns (route_info_ptr, refs) where refs must be kept alive for the duration of the FFI call.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
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 | |
parse_push_notification(ffi, kind, message_ptr, message_len, channel_ptr, channel_len, pattern_ptr, pattern_len)
Parse raw FFI push notification data into (message_kind, message_bytes, channel_bytes, pattern_bytes).
Returns (kind_str, message, channel, pattern) where pattern may be None.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
convert_commands_to_c_batch_info(ffi, commands, is_atomic)
Convert a list of (request_type, args) tuples to a C BatchInfo*.
Returns (batch_info, refs) where refs must be kept alive during the FFI call.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
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 | |
create_c_batch_options(ffi, route, retry_server_error=False, retry_connection_error=False, timeout=None)
Create a C BatchOptionsInfo* from Python parameters.
Returns (batch_options, refs) where refs must be kept alive during the FFI call.
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
create_address_resolver_callback(ffi, resolver_fn)
Create an AddressResolverCallback for the FFI from a Python resolver function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
The CFFI instance. |
required | |
resolver_fn
|
A callable(host: str, port: int) -> (resolved_host: str, resolved_port: int). |
required |
Returns:
| Type | Description |
|---|---|
|
The CFFI callback object. Caller must keep a reference to prevent GC. |
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
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 | |
handle_command_result(ffi, lib, command_result, response_handler)
Handle a synchronous CommandResult* from FFI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ffi
|
The CFFI instance. |
required | |
lib
|
The FFI library. |
required | |
command_result
|
The CommandResult* pointer from FFI. |
required | |
response_handler
|
A callable that takes a response pointer and returns the parsed result. |
required |
Returns:
| Type | Description |
|---|---|
|
The parsed response value. |
Raises:
| Type | Description |
|---|---|
ClosingError
|
If result is NULL. |
RequestError subclass
|
If the result contains an error. |
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
parse_inline_pubsub(payload)
Parse inline pubsub payload from pipe.
Format: kind(4) msg_len(4) msg(...) ch_len(4) ch(...) pat_len(4) pat(...)
Source code in doc-gen/valkey-glide/python/glide-shared/glide_shared/ffi_helpers.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |