Skip to content

Commit da89587

Browse files
authored
Merge pull request #61 from getoptimum/docs/add-start-end-index-documentation
docs: add docs for start and end index flags
2 parents c09d932 + c99c5f6 commit da89587

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ grpc_p2p_client/remote-ips.txt
1717

1818
# Output files
1919
*.txt
20+
*.tsv
2021
!grpc_p2p_client/local.ips.tsv

docs/guide.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,9 +1077,48 @@ Then publish to all nodes in the file:
10771077
**Flags:**
10781078
- `-topic`: Topic name to publish to (required)
10791079
- `-ipfile`: File containing IP addresses, one per line (required)
1080+
- `-start-index`: Starting index in IP file for selecting a subset of IPs (default: 0)
1081+
- `-end-index`: Ending index in IP file (exclusive, default: 10000)
10801082
- `-count`: Number of messages to publish per node (default: 1)
10811083
- `-sleep`: Delay between messages (e.g., `500ms`, `1s`)
10821084

1085+
**Index Range Selection (`-start-index` and `-end-index`):**
1086+
1087+
These flags allow you to select a specific range of IP addresses from your IP file, which is useful when:
1088+
- Testing with a subset of nodes from a large IP file
1089+
- Running parallel tests across different IP ranges
1090+
1091+
**How it works:**
1092+
- Uses **zero-based indexing** (first IP is at index 0)
1093+
- `-end-index` is **exclusive** (like Python slicing: `ips[start:end]`)
1094+
- If your IP file has 10 IPs and you use `-start-index=0 -end-index=5`, it will use IPs at indices 0, 1, 2, 3, 4 (5 IPs total)
1095+
- If `-end-index` exceeds the number of IPs in the file, it automatically caps to the file length
1096+
- Both flags must be valid: `start-index >= 0`, `start-index < end-index`, and `start-index < total IPs`
1097+
1098+
**Examples:**
1099+
1100+
```sh
1101+
# Publish to first 5 IPs (indices 0-4)
1102+
./grpc_p2p_client/p2p-multi-publish \
1103+
-topic=test-topic \
1104+
-ipfile=ips.txt \
1105+
-start-index=0 \
1106+
-end-index=5 \
1107+
-count=10
1108+
1109+
# Publish to IPs 10-19 (indices 10-19)
1110+
./grpc_p2p_client/p2p-multi-publish \
1111+
-topic=test-topic \
1112+
-ipfile=ips.txt \
1113+
-start-index=10 \
1114+
-end-index=20 \
1115+
-count=10
1116+
1117+
# If not specified, defaults to start-index=0, end-index=10000
1118+
# (or file length if less than 10000 IPs)
1119+
./grpc_p2p_client/p2p-multi-publish -topic=test-topic -ipfile=ips.txt
1120+
```
1121+
10831122
**Example Output:**
10841123
```
10851124
Found 4 IPs: [localhost:33221 localhost:33222 localhost:33223 localhost:33224]
@@ -1111,11 +1150,13 @@ Subscribe to multiple nodes and collect messages:
11111150
**Flags:**
11121151
- `-topic`: Topic name to subscribe to (required)
11131152
- `-ipfile`: File containing IP addresses, one per line (required)
1114-
- `-start-index`: Starting index in IP file (default: 0)
1115-
- `-end-index`: Ending index in IP file (default: 10000)
1153+
- `-start-index`: Starting index in IP file for selecting a subset of IPs (default: 0)
1154+
- `-end-index`: Ending index in IP file (exclusive, default: 10000)
11161155
- `-output-data`: Output file for message data (TSV format: receiver, sender, size, sha256)
11171156
- `-output-trace`: Output file for trace events (TSV format: type, peerID, receivedFrom, messageID, topic, timestamp)
11181157

1158+
**Note:** The `-start-index` and `-end-index` flags work the same way as described in the Multi-Node Publisher Usage section above.
1159+
11191160
**Example Output:**
11201161
```
11211162
numip 4 index 10000

0 commit comments

Comments
 (0)