pyraftlog is a RAFT consensus algorithm implementation that provides direct access to the consensus log.
Consensus Nodes can be instantiated into defined mode, but can also have its mode changed via an RPC. There are three modes a node can be in:
- Active
A fully-fledged consensus node which will attempt to take leadership of the cluster if a leadership timeout is reached.
- Reluctant
A consensus node which will reluctantly take leadership of the cluster while there is no eligible candidate. As soon as there is an eligible active node a reluctant node will rescind its leadership.
- Passive
A consensus node which that will respond to all vote requests but will never convert itself to a candidate. This mode can be useful in testing or development environments but shouldn’t be used in production.
Consensus Nodes can enable log reduction, this can be useful in certain situations where a complete history of actions is not required or would take considerable storage to retain. If log_reduction is set to True in the state then the cluster will automatically reduce the log to the most recent last_applied index that is shared across the cluster. Have log reduction set to True would make it difficult to add additional nodes to the cluster.
Mock Server
There is a mock server that can be run by calling pyraftlog-mock:
usage: pyraftlog-mock [-h] [-t {active,reluctant,passive}] -n NODE -b
NEIGHBOURS [NEIGHBOURS ...] [-p PORT] [-r]
[-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-f FILE]
Run a mock localhost pyraftlog server
optional arguments:
-h, --help show this help message and exit
-t {active,reluctant,passive}, --type {active,reluctant,passive}
Type of the node
-n NODE, --node NODE (host:)?port of this node. e.g. 7001 or node:7001
-b NEIGHBOURS [NEIGHBOURS ...], --neighbours NEIGHBOURS [NEIGHBOURS ...]
Port(s) of neighbour
-p PORT, --port PORT Port for receiving commands
-r, --log-reduction Set log reduction to True
-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
Logging level
-f FILE, --file FILE Storage filename
Create SSL certs (for mock)
The following set of commands (performed in ./certs/) will create a set a CA and device certificate for running the mock cluster on localhost:
# Only do once: generate the root CA key: > openssl genrsa -out transport-ca.key 4096 # Generate the root CA certificate: ## Country Name (2 letter code) []:GB ## State or Province Name (full name) []:. ## Locality Name (eg, city) []:. ## Organization Name (eg, company) []:. ## Organizational Unit Name (eg, section) []:. ## Common Name (eg, fully qualified host name) []:PyRaftLog ## Email Address []:. > openssl req -x509 -new -nodes -key transport-ca.key -sha256 -days 1024 -out transport-ca.pem # Generate device certificates # Only do once: generate device key: > openssl genrsa -out transport-consensus.key 4096 # Generate device certificate signing request: ## Country Name (2 letter code) []:GB ## State or Province Name (full name) []:. ## Locality Name (eg, city) []:. ## Organization Name (eg, company) []:. ## Organizational Unit Name (eg, section) []:. ## Common Name (eg, fully qualified host name) []:localhost ## Email Address []:. > openssl req -new -key transport-consensus.key -out transport-consensus.csr # Generate a signed device certificate: > openssl x509 -req -in transport-consensus.csr -CA transport-ca.pem -CAkey transport-ca.key -CAcreateserial -out transport-consensus.crt -days 500 -sha256
Also See
Raft lecture (Raft user study)
Metadata
Release files for pyraftlog 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyraftlog-3.0.0.tar.gz | 30.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyraftlog-3.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 63.9 kB
Release files / pyraftlog-3.0.0.tar.gz
| Download URL | pyraftlog-3.0.0.tar.gz |
|---|---|
| Size | 30.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ee75a4f08daa1b450ffb26bbdc2ad71214b8f99fb999f7cf8ed69801a07b2d9a
|
|
BLAKE2b-256 checksum How to use checksums |
3d6e759e81b9aec136f68666d753a8a609370b8f2ac13a5cd09abb6e3853fcc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.4
|
Release files / pyraftlog-3.0.0-py3-none-any.whl
| Download URL | pyraftlog-3.0.0-py3-none-any.whl |
|---|---|
| Size | 33.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
813f65b95a026c292ca95b30b1b3b9a34af6de1bf0dc3d34b1d23b01c6e91e7f
|
|
BLAKE2b-256 checksum How to use checksums |
781be32e70799f0b268739857f487d7626fd02c92400b164acb7cd9b86c682e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.4
|
Security for pyraftlog 3.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.