Single HandlerSocket connection.
Maintains a streamed socket connection and defines methods to send and read data from it. In case of failure retry_time will be set to the exact time after which the connection may be retried to deal with temporary connection issues.
Parameters: |
|
---|
Establishes connection with a new socket. If some socket is associated with the instance - no new socket will be created.
Closes a socket and disassociates it from the connection instance.
Note
It ignores any socket exceptions that might happen in process.
Checks if connection instance is ready to be used.
Return type: | bool |
---|
Reads one line from the socket stream and returns it. Lines are expected to be delimited with LF. Throws ConnectionError in case of failure.
Return type: | string |
---|
Note
Currently Connection class supports only one line per request/response. All data in the stream after first LF will be ignored.
Sends all given data into the socket stream. Throws ConnectionError in case of failure.
Parameters: | data (string) – data to send |
---|
Changes debugging mode of the connection. If enabled, some debugging info will be printed to stdout.
Parameters: | mode (bool) – mode value |
---|
Pool of HandlerSocket connections.
Manages connections and defines common HandlerSocket operations. Uses internal index id cache. Subclasses threading.local to put connection pool and indexes data in thread-local storage as they’re not safe to share between threads.
Warning
Shouldn’t be used directly in most cases. Use ReadSocket for read operations and WriteSocket for writes.
Pool constructor initializes connections for all given HandlerSocket servers.
Parameters: |
|
---|
Returns index id for given index data. This id must be used in all operations that use given data.
Uses internal index cache that keys index ids on a combination of: db:table:index_name:fields. In case no index was found in the cache, a new index will be opened.
Note
fields is position-dependent, so change of fields order will open a new index with another index id.
Parameters: |
|
---|---|
Return type: | integer or None |
Closes all connections, cleans caches, zeroes index id counter.
Clear single index connection and cache.
Parameters: | index_id (integer) – id of the index to purge. |
---|
Closes all indexed connections, cleans caches, zeroes index id counter.
HandlerSocket client for read operations.
Pool constructor initializes connections for all given HandlerSocket servers.
Parameters: |
|
---|
Finds row(s) via opened index.
Raises ValueError if given data doesn’t validate.
Parameters: |
|
---|---|
Return type: | list |
HandlerSocket client for write operations.
Pool constructor initializes connections for all given HandlerSocket servers.
Parameters: |
|
---|
Updates/deletes row(s) using opened index.
Returns number of modified rows or a list of original values in case modify_operation ends with ?.
Raises ValueError if given data doesn’t validate.
Parameters: |
|
---|---|
Return type: | list |
Inserts single row using opened index.
Raises ValueError if given data doesn’t validate.
Parameters: |
|
---|---|
Return type: | bool |