|
3 | 3 | ## Introduction |
4 | 4 |
|
5 | 5 | The libasyncproxy is a fairy simple C library and a respective python wrapper, |
6 | | -which allows connecting two sockets and relay data in/out in a background |
7 | | -using a worker thread (one per connection at the moment). |
| 6 | +which allows splicing two sockets, pipes and in general file descriptors to |
| 7 | +relay bidirectional data in/out in a background using a worker thread (one per |
| 8 | +connection at the moment). |
| 9 | + |
| 10 | +Unlike system-wide facilities that might be offering similar functionality, |
| 11 | +this library provides more control and flexibility. Allowing to connect |
| 12 | +different kinds of underlying objects (i.e. plain file to a socket, device to |
| 13 | +a pipe etc). |
| 14 | + |
| 15 | +It also privides mechanism for the python code to supply a handler(s) to |
| 16 | +monitor, record and/or alter the data being transmitted. |
| 17 | + |
| 18 | +Last but not least, the C library can be used directly from a low-level code |
| 19 | +for the same effect. |
8 | 20 |
|
9 | 21 | ## History |
10 | 22 |
|
11 | 23 | The code was created to allow Python code implementing application-layer proxy |
12 | 24 | to manage session routing and connection, while handling all transfers outside |
13 | 25 | of confinments of the slow Python and its GIL. |
14 | 26 |
|
| 27 | +## Interfaces |
| 28 | + |
| 29 | +AsyncProxy: the lowest-level interface, dealing with raw sockets, wrapper for |
| 30 | +libasyncproxy. |
| 31 | + |
| 32 | +ForwarderFast: super-set of AsyncProxy with some utility methods. |
| 33 | + |
| 34 | +Forwarder: same API and functionality as ForwarderFast, but without using |
| 35 | +AsyncProxy C module (i.e. python thread doing i/o). Mostly for backward |
| 36 | +compatibility when we need to break library API. |
| 37 | + |
| 38 | +TCPProxy: set of high-level classes to accept and manage inbound connections |
| 39 | +and initiate/tear-down outbound as needed, connecting them using forwarders |
| 40 | +once established. Will use ForwarderFast if available, falling back to the |
| 41 | +Forwarder if that fails. |
| 42 | + |
| 43 | +## Use Cases |
| 44 | + |
| 45 | +We use this library to allow applications to be redirected to one of several |
| 46 | +available DB replicas and re-routed instantly if the configuration changes. |
| 47 | + |
15 | 48 | ## Build and Install Python module from source code: |
16 | 49 |
|
17 | 50 | ``` |
18 | 51 | git clone https://github.com/sippy/libasyncproxy.git |
19 | 52 | pip install libasyncproxy/ |
20 | 53 | ``` |
| 54 | + |
| 55 | +## Usage |
0 commit comments