⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on Network monitoring, controls & Application development, testing, debugging.
2013-present by Abhinav Singh and contributors.
BSD, see LICENSE for more details.
- class proxy.core.event.subscriber.EventSubscriber(event_queue: proxy.core.event.queue.EventQueue, callback: Callable[[Dict[str, Any]], None])[source]#
Core event subscriber.
Usage: Initialize one instance per CPU core for optimum performance.
EventSubscriber can run within various context. E.g. main thread, another thread or a different process. EventSubscriber context can be different from publishers. Publishers can even be processes outside of the proxy.py core.
multiprocessing.Pipeis used to initialize a new Queue for receiving subscribed events from eventing core. Note that, core EventDispatcher might be running in a separate process and hence subscription queue must be multiprocess safe.
subscribemethod is called, EventManager stars a relay thread which consumes event out of the subscription queue and invoke callback.
NOTE: Callback is executed in the context of relay thread.
- static relay(sub_id: str, shutdown: threading.Event, channel: multiprocessing.connection.Connection, callback: Callable[[Dict[str, Any]], None]) None [source]#
- setup(do_subscribe: bool = True) None [source]#
Setup subscription thread.
Call subscribe() to actually start subscription.
- shutdown(do_unsubscribe: bool = True) None [source]#
Tear down subscription thread.
Call unsubscribe() to actually stop subscription.