Skip to content

Commit 96d8d73

Browse files
committed
chore: readme
Signed-off-by: Fawzi Abdulfattah <iifawzie@gmail.com>
1 parent f03646a commit 96d8d73

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

README.md

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,61 @@ The implementation of tf-raft is based on the ["CONSENSUS: BRIDGING THEORY AND P
1212

1313
In short, Raft achieves consensus through a leader-follower model, where one node serves as the leader and others as followers. The leader is responsible for coordinating the consensus process, and all updates go through the leader to ensure consistency.
1414

15-
1615
tf-raft implements the three core components of the RAFT Consensus Protocol:
16+
1717
1. **Leader Election:** The process by which a leader is chosen among the nodes.
1818
2. **Log Replication:** Ensuring that the logs across nodes are consistent through replication.
1919
3. **Cluster Membership Changes:** Handling dynamic changes in the cluster, such as adding or removing nodes.
2020

2121
The core of tf-raft is fully isolated and independent from the infrastructure, relying on ports and adapters for high flexibility.
22-
tf-raft currently supports `gRPC` and `In-Memory` adapters for the network layer & `In-Memory` and `JSON-Based` adapters for volatile and non-volatile states, respectively.
22+
tf-raft currently supports `gRPC` and `In-Memory` adapters for the network layer & `In-Memory` and `JSON-Based` adapters for volatile and non-volatile states, respectively.
2323

24-
## Commands and Usage
24+
## Store Commands
2525

2626
Below are the commands supported by tf-raft, along with their descriptions and example usage:
2727

28-
| Command | Description | Example Usage |
29-
|-------------------------------------------|---------------------------------------------------------|-----------------------------------------|
30-
| `SET KEY VALUE` | Set the value of a key | `SET my_key 42` |
31-
| `GET KEY` | Retrieve the value of a key | `GET my_key` |
32-
| `DEL KEY` | Delete a key and its associated value | `DEL my_key` |
33-
| `HDEL hash_name key1 [key2 key3 ...]` | Delete one or more fields from a hash | `HDEL my_hash field1 field2` |
34-
| `HSET hash_name key1:value1 [key2:value2 ...]` | Set multiple field values in a hash | `HSET user_info username:john email:john@example.com` |
35-
| `HGET hash_name key` | Get the value associated with a field in a hash | `HGET user_info username` |
36-
| `SDEL set_name value1 [value2 value ...]` | Remove one or more members from a set | `SDEL my_set member1 member2` |
37-
| `SHAS set_name value` | Check if a value is a member of a set | `SHAS my_set member` |
38-
| `SSET set_name value1 [value2 ...]` | Add one or more members to a set | `SSET my_set value1 value2` |
28+
| Command | Description | Example Usage |
29+
| ---------------------------------------------- | ----------------------------------------------- | ----------------------------------------------------- |
30+
| `SET KEY VALUE` | Set the value of a key | `SET my_key 42` |
31+
| `GET KEY` | Retrieve the value of a key | `GET my_key` |
32+
| `DEL KEY` | Delete a key and its associated value | `DEL my_key` |
33+
| `HDEL hash_name key1 [key2 key3 ...]` | Delete one or more fields from a hash | `HDEL my_hash field1 field2` |
34+
| `HSET hash_name key1:value1 [key2:value2 ...]` | Set multiple field values in a hash | `HSET user_info username:john email:john@example.com` |
35+
| `HGET hash_name key` | Get the value associated with a field in a hash | `HGET user_info username` |
36+
| `SDEL set_name value1 [value2 value ...]` | Remove one or more members from a set | `SDEL my_set member1 member2` |
37+
| `SHAS set_name value` | Check if a value is a member of a set | `SHAS my_set member` |
38+
| `SSET set_name value1 [value2 ...]` | Add one or more members to a set | `SSET my_set value1 value2` |
3939

4040
Please note that tf-raft is not intended for production use and serves solely as an educational tool.
4141

42+
## Installation & Usage
43+
44+
### Install Dependencies
45+
46+
```bash
47+
npm install
48+
```
49+
50+
### Start the tf-raft Cluster
51+
52+
```bash
53+
npm run start [memory, RPC] [number_of_nodes]
54+
```
55+
56+
<ul>
57+
<li><strong>Optional Parameters:</strong></li>
58+
<ul>
59+
<li><code>memory</code> or <code>RPC</code>: Specify the protocol for network communication (default is <code>memory</code>).</li>
60+
<li><code>number_of_nodes</code>: Specify the number of nodes in the cluster (default is 3). The number must be 3 or larger.</li>
61+
</ul>
62+
</ul>
63+
64+
After running the start command, a command-line prompt will be available to issue the commands mentioned above.
65+
4266
## License
4367

4468
[MIT](LICENSE)
4569

4670
## Copyright
4771

48-
Copyright (c) 2023 Fawzi Abdulfattah
72+
Copyright (c) 2023 Fawzi Abdulfattah

0 commit comments

Comments
 (0)