File: extend-patterns.py

package info (click to toggle)
python-aio-pika 9.5.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 1,460 kB
  • sloc: python: 8,003; makefile: 37; xml: 1
file content (25 lines) | stat: -rw-r--r-- 568 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from typing import Any

import msgpack  # type: ignore

from aio_pika.patterns import RPC, Master


class MsgpackRPC(RPC):
    CONTENT_TYPE = "application/msgpack"

    def serialize(self, data: Any) -> bytes:
        return msgpack.dumps(data)

    def deserialize(self, data: bytes) -> bytes:
        return msgpack.loads(data)


class MsgpackMaster(Master):
    CONTENT_TYPE = "application/msgpack"

    def serialize(self, data: Any) -> bytes:
        return msgpack.dumps(data)

    def deserialize(self, data: bytes) -> bytes:
        return msgpack.loads(data)