Skip to content

Commit 2659ad9

Browse files
authored
Merge pull request #741 from bugout-dev/nodebalancer-tags
Supports tags filter for nodes
2 parents bd85f48 + 87d034f commit 2659ad9

File tree

10 files changed

+288
-185
lines changed

10 files changed

+288
-185
lines changed

nodes/node_balancer/README.md

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,49 @@
11
# Node Balancer application
22

3-
# Installation
3+
## Installation and configuration
44

5-
- Prepare environment variables
5+
- Prepare environment variables, according with `sample.env`.
66
- Build application
77

88
```bash
99
go build -o nodebalancer .
1010
```
1111

12-
# Work with nodebalancer
12+
- Generate configuration
1313

14-
## add-access
14+
```bash
15+
nodebalancer generate-config
16+
```
17+
18+
- Modify configuration. Tags should NOT repeat blockchain, as it is specified in `blockchain` key. Example of configuration:
19+
20+
```bash
21+
[
22+
{
23+
"blockchain": "ethereum",
24+
"endpoint": "http://127.0.0.1:8545",
25+
"tags": ["local"]
26+
},
27+
{
28+
"blockchain": "ethereum",
29+
"endpoint": "http://127.0.0.1:9585",
30+
"tags": ["local"]
31+
},
32+
{
33+
"blockchain": "ethereum",
34+
"endpoint": "https://cool-name.quiknode.pro/y0urn0de1den1f1cat0r/",
35+
"tags": ["external"]
36+
}
37+
]
38+
```
39+
40+
So if with request will be specified tag `local` will be returned node with corresponding tag.
41+
42+
## Work with nodebalancer
43+
44+
**IMPORTANT** Do not use flag `-debug` in production.
45+
46+
### add-access
1547

1648
Add new access for user:
1749

@@ -25,7 +57,7 @@ nodebalancer add-access \
2557
--blockchain--access true
2658
```
2759

28-
## delete-access
60+
### delete-access
2961

3062
Delete user access:
3163

@@ -37,7 +69,7 @@ nodebalancer delete-access \
3769

3870
If `access-id` not specified, all user accesses will be deleted.
3971

40-
## users
72+
### users
4173

4274
```bash
4375
nodebalancer users | jq .
@@ -67,7 +99,7 @@ This command will return a list of bugout resources of registered users to acces
6799

68100
`extended_methods` - boolean which allow you to call not whitelisted method to blockchain node, by default for new user this is equal to `false`
69101

70-
## server
102+
### server
71103

72104
```bash
73105
nodebalancer server -host 0.0.0.0 -port 8544 -healthcheck
@@ -76,17 +108,17 @@ nodebalancer server -host 0.0.0.0 -port 8544 -healthcheck
76108
Flag `--healthcheck` will execute background process to ping-pong available nodes to keep their status and current block number.
77109
Flag `--debug` will extend output of each request to server and healthchecks summary.
78110

79-
# Work with node
111+
## Work with node
80112

81113
Common request to fetch block number
82114

83115
```bash
84-
curl --request GET 'http://127.0.0.1:8544/nb/ethereum/jsonrpc?access_id=<access_id>&data_source=<blockchain/database>' \
116+
curl --request POST 'http://127.0.0.1:8544/nb/ethereum/jsonrpc?access_id=<access_id>&data_source=<blockchain/database>' \
85117
--header 'Content-Type: application/json' \
86118
--data-raw '{
87119
"jsonrpc":"2.0",
88120
"method":"eth_getBlockByNumber",
89-
"params":["0xb71b64", false],
121+
"params":["latest", false],
90122
"id":1
91123
}'
92124
```
@@ -97,3 +129,16 @@ For Web3 providers `access_id` and `data_source` could be specified in headers
97129
--header 'x-node-balancer-data-source: <blockchain/database>'
98130
--header 'x-node-balancer-access-id: <access_id>'
99131
```
132+
133+
Same request to fetch specific nodes using tags
134+
135+
```bash
136+
curl --request POST 'http://127.0.0.1:8544/nb/ethereum/jsonrpc?access_id=<access_id>&data_source=<blockchain/database>&tag=<specific_tag_1>&tag=<specific_tag_2>' \
137+
--header 'Content-Type: application/json' \
138+
--data-raw '{
139+
"jsonrpc":"2.0",
140+
"method":"eth_getBlockByNumber",
141+
"params":["latest", false],
142+
"id":1
143+
}'
144+
```

0 commit comments

Comments
 (0)