txredisapi.pyi 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Copyright 2020 The Matrix.org Foundation C.I.C.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """Contains *incomplete* type hints for txredisapi.
  15. """
  16. from typing import Any, List, Optional, Type, Union
  17. from twisted.internet import protocol
  18. class RedisProtocol(protocol.Protocol):
  19. def publish(self, channel: str, message: bytes): ...
  20. async def ping(self) -> None: ...
  21. async def set(
  22. self,
  23. key: str,
  24. value: Any,
  25. expire: Optional[int] = None,
  26. pexpire: Optional[int] = None,
  27. only_if_not_exists: bool = False,
  28. only_if_exists: bool = False,
  29. ) -> None: ...
  30. async def get(self, key: str) -> Any: ...
  31. class SubscriberProtocol(RedisProtocol):
  32. def __init__(self, *args, **kwargs): ...
  33. password: Optional[str]
  34. def subscribe(self, channels: Union[str, List[str]]): ...
  35. def connectionMade(self): ...
  36. def connectionLost(self, reason): ...
  37. def lazyConnection(
  38. host: str = ...,
  39. port: int = ...,
  40. dbid: Optional[int] = ...,
  41. reconnect: bool = ...,
  42. charset: str = ...,
  43. password: Optional[str] = ...,
  44. connectTimeout: Optional[int] = ...,
  45. replyTimeout: Optional[int] = ...,
  46. convertNumbers: bool = ...,
  47. ) -> RedisProtocol: ...
  48. class ConnectionHandler: ...
  49. class RedisFactory(protocol.ReconnectingClientFactory):
  50. continueTrying: bool
  51. handler: RedisProtocol
  52. pool: List[RedisProtocol]
  53. replyTimeout: Optional[int]
  54. def __init__(
  55. self,
  56. uuid: str,
  57. dbid: Optional[int],
  58. poolsize: int,
  59. isLazy: bool = False,
  60. handler: Type = ConnectionHandler,
  61. charset: str = "utf-8",
  62. password: Optional[str] = None,
  63. replyTimeout: Optional[int] = None,
  64. convertNumbers: Optional[int] = True,
  65. ): ...
  66. def buildProtocol(self, addr) -> RedisProtocol: ...
  67. class SubscriberFactory(RedisFactory):
  68. def __init__(self) -> None: ...