| 25 | |
| 26 | |
| 27 | class Response: |
| 28 | __slots__ = ("_data", "_address", "_request_id", "_duration", "_from_command", "_docs") |
| 29 | |
| 30 | def __init__( |
| 31 | self, |
| 32 | data: Union[_OpMsg, _OpReply], |
| 33 | address: _Address, |
| 34 | request_id: int, |
| 35 | duration: Optional[timedelta], |
| 36 | from_command: bool, |
| 37 | docs: Sequence[Mapping[str, Any]], |
| 38 | ): |
| 39 | """Represent a response from the server. |
| 40 | |
| 41 | :param data: A network response message. |
| 42 | :param address: (host, port) of the source server. |
| 43 | :param request_id: The request id of this operation. |
| 44 | :param duration: The duration of the operation. |
| 45 | :param from_command: if the response is the result of a db command. |
| 46 | """ |
| 47 | self._data = data |
| 48 | self._address = address |
| 49 | self._request_id = request_id |
| 50 | self._duration = duration |
| 51 | self._from_command = from_command |
| 52 | self._docs = docs |
| 53 | |
| 54 | @property |
| 55 | def data(self) -> Union[_OpMsg, _OpReply]: |
| 56 | """Server response's raw BSON bytes.""" |
| 57 | return self._data |
| 58 | |
| 59 | @property |
| 60 | def address(self) -> _Address: |
| 61 | """(host, port) of the source server.""" |
| 62 | return self._address |
| 63 | |
| 64 | @property |
| 65 | def request_id(self) -> int: |
| 66 | """The request id of this operation.""" |
| 67 | return self._request_id |
| 68 | |
| 69 | @property |
| 70 | def duration(self) -> Optional[timedelta]: |
| 71 | """The duration of the operation.""" |
| 72 | return self._duration |
| 73 | |
| 74 | @property |
| 75 | def from_command(self) -> bool: |
| 76 | """If the response is a result from a db command.""" |
| 77 | return self._from_command |
| 78 | |
| 79 | @property |
| 80 | def docs(self) -> Sequence[Mapping[str, Any]]: |
| 81 | """The decoded document(s).""" |
| 82 | return self._docs |
| 83 | |
| 84 |
no outgoing calls
no test coverage detected