1
0

txredisapi.pyi 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2020 The Matrix.org Foundation C.I.C.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. """Contains *incomplete* type hints for txredisapi.
  16. """
  17. from typing import Any, List, Optional, Type, Union
  18. from twisted.internet import protocol
  19. class RedisProtocol(protocol.Protocol):
  20. def publish(self, channel: str, message: bytes): ...
  21. async def ping(self) -> None: ...
  22. async 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. ) -> None: ...
  31. async def get(self, key: str) -> 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): ...