MCPcopy
hub / github.com/benoitc/gunicorn / encode_stash

Method encode_stash

gunicorn/dirty/protocol.py:326–356  ·  view source on GitHub ↗

Encode a stash operation message. Args: request_id: Unique request identifier (uint64) op: Stash operation code (STASH_OP_*) table: Table name key: Optional key for put/get/delete operations value: Optional value for put o

(request_id: int, op: int, table: str,
                     key=None, value=None, pattern=None)

Source from the content-addressed store, hash-verified

324
325 @staticmethod
326 def encode_stash(request_id: int, op: int, table: str,
327 key=None, value=None, pattern=None) -> bytes:
328 """
329 Encode a stash operation message.
330
331 Args:
332 request_id: Unique request identifier (uint64)
333 op: Stash operation code (STASH_OP_*)
334 table: Table name
335 key: Optional key for put/get/delete operations
336 value: Optional value for put operation
337 pattern: Optional pattern for keys operation
338
339 Returns:
340 bytes: Complete message (header + payload)
341 """
342 payload_dict = {
343 "op": op,
344 "table": table,
345 }
346 if key is not None:
347 payload_dict["key"] = key
348 if value is not None:
349 payload_dict["value"] = value
350 if pattern is not None:
351 payload_dict["pattern"] = pattern
352
353 payload = TLVEncoder.encode(payload_dict)
354 header = BinaryProtocol.encode_header(MSG_TYPE_STASH, request_id,
355 len(payload))
356 return header + payload
357
358 @staticmethod
359 def decode_message(data: bytes) -> tuple:

Callers 1

_encode_from_dictMethod · 0.80

Calls 2

encodeMethod · 0.80
encode_headerMethod · 0.80

Tested by

no test coverage detected