txredisapi.pyi 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. from twisted.internet.defer import Deferred
  19. class RedisProtocol(protocol.Protocol):
  20. def publish(self, channel: str, message: bytes): ...
  21. def ping(self) -> "Deferred[None]": ...
  22. def set(
  23. self,
  24. key: str,
  25. value: Any,
  26. expire: Optional[int] = None,
  27. pexpire: Optional[int] = None,
  28. only_if_not_exists: bool = False,
  29. only_if_exists: bool = False,
  30. ) -> "Deferred[None]": ...
  31. def get(self, key: str) -> "Deferred[Any]": ...
  32. class SubscriberProtocol(RedisProtocol):
  33. def __init__(self, *args, **kwargs): ...
  34. password: Optional[str]
  35. def subscribe(self, channels: Union[str, List[str]]): ...
  36. def connectionMade(self): ...
  37. def connectionLost(self, reason): ...
  38. def lazyConnection(
  39. host: str = ...,
  40. port: int = ...,
  41. dbid: Optional[int] = ...,
  42. reconnect: bool = ...,
  43. charset: str = ...,
  44. password: Optional[str] = ...,
  45. connectTimeout: Optional[int] = ...,
  46. replyTimeout: Optional[int] = ...,
  47. convertNumbers: bool = ...,
  48. ) -> RedisProtocol: ...
  49. class ConnectionHandler: ...
  50. class RedisFactory(protocol.ReconnectingClientFactory):
  51. continueTrying: bool
  52. handler: RedisProtocol
  53. pool: List[RedisProtocol]
  54. replyTimeout: Optional[int]
  55. def __init__(
  56. self,
  57. uuid: str,
  58. dbid: Optional[int],
  59. poolsize: int,
  60. isLazy: bool = False,
  61. handler: Type = ConnectionHandler,
  62. charset: str = "utf-8",
  63. password: Optional[str] = None,
  64. replyTimeout: Optional[int] = None,
  65. convertNumbers: Optional[int] = True,
  66. ): ...
  67. def buildProtocol(self, addr) -> RedisProtocol: ...
  68. class SubscriberFactory(RedisFactory):
  69. def __init__(self) -> None: ...