initial candle request limit, better error reporting, split up _handle_producer_connection

This commit is contained in:
Timothy Pogue
2022-09-02 15:05:16 -06:00
parent 5b0b802f31
commit cf917ad2f5
6 changed files with 119 additions and 50 deletions

View File

@@ -1,4 +1,4 @@
from typing import Union
from typing import Any, Tuple, Union
from fastapi import WebSocket as FastAPIWebSocket
from websockets import WebSocketClientProtocol as WebSocket
@@ -15,6 +15,14 @@ class WebSocketProxy:
def __init__(self, websocket: WebSocketType):
self._websocket: Union[FastAPIWebSocket, WebSocket] = websocket
@property
def remote_addr(self) -> Tuple[Any, ...]:
if hasattr(self._websocket, "remote_address"):
return self._websocket.remote_address
elif hasattr(self._websocket, "client"):
return tuple(self._websocket.client)
return ("unknown", 0)
async def send(self, data):
"""
Send data on the wrapped websocket