Skip to content

Commit

Permalink
Reverse proxy plugin constructor now accepts client connection object (
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavsingh authored Jul 30, 2022
1 parent dc06ea4 commit 9d9bbd1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions proxy/http/server/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ def on_access_log(self, context: Dict[str, Any]) -> Optional[Dict[str, Any]]:
class ReverseProxyBasePlugin(ABC):
"""ReverseProxy base plugin class."""

def __init__(
self,
uid: str,
flags: argparse.Namespace,
client: HttpClientConnection,
event_queue: EventQueue,
upstream_conn_pool: Optional['UpstreamConnectionPool'] = None,
):
self.uid = uid
self.flags = flags
self.client = client
self.event_queue = event_queue
self.upstream_conn_pool = upstream_conn_pool

@abstractmethod
def routes(self) -> List[Union[str, Tuple[str, List[bytes]]]]:
"""List of routes registered by plugin.
Expand Down
4 changes: 3 additions & 1 deletion proxy/http/server/reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def __init__(self, *args: Any, **kwargs: Any):
self.choice: Optional[Url] = None
self.plugins: List['ReverseProxyBasePlugin'] = []
for klass in self.flags.plugins[b'ReverseProxyBasePlugin']:
plugin: 'ReverseProxyBasePlugin' = klass()
plugin: 'ReverseProxyBasePlugin' = klass(
self.uid, self.flags, self.client, self.event_queue, self.upstream_conn_pool,
)
self.plugins.append(plugin)

def handle_upstream_data(self, raw: memoryview) -> None:
Expand Down

0 comments on commit 9d9bbd1

Please sign in to comment.