Skip to content

Commit 87d034f

Browse files
committed
Updated README.md and debug logs
1 parent b4ca416 commit 87d034f

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

nodes/node_balancer/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ So if with request will be specified tag `local` will be returned node with corr
4141

4242
## Work with nodebalancer
4343

44+
**IMPORTANT** Do not use flag `-debug` in production.
45+
4446
### add-access
4547

4648
Add new access for user:
@@ -127,3 +129,16 @@ For Web3 providers `access_id` and `data_source` could be specified in headers
127129
--header 'x-node-balancer-data-source: <blockchain/database>'
128130
--header 'x-node-balancer-access-id: <access_id>'
129131
```
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+
```

nodes/node_balancer/cmd/nodebalancer/middleware.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func initCacheCleaning() {
105105
case <-t.C:
106106
removedAccessIds, totalAccessIds := accessIdCache.Cleanup()
107107
if stateCLI.enableDebugFlag {
108-
log.Printf("Removed %d elements from access id cache", removedAccessIds)
108+
log.Printf("[DEBUG] Removed %d elements from access id cache", removedAccessIds)
109109
}
110110
log.Printf("Elements in access id cache: %d", totalAccessIds)
111111
}
@@ -241,7 +241,7 @@ func logMiddleware(next http.Handler) http.Handler {
241241

242242
if stateCLI.enableDebugFlag {
243243
if r.URL.RawQuery != "" {
244-
logStr += fmt.Sprintf(" %s", r.URL.RawQuery)
244+
logStr += fmt.Sprintf(" [DEBUG] %s", r.URL.RawQuery)
245245
}
246246
accessID := extractAccessID(r)
247247
if accessID != "" {
@@ -269,20 +269,20 @@ func accessMiddleware(next http.Handler) http.Handler {
269269
// If access id does not belong to internal crawlers, then check cache or find it in Bugout resources
270270
if accessID == NB_CONTROLLER_ACCESS_ID {
271271
if stateCLI.enableDebugFlag {
272-
log.Printf("Access id belongs to internal crawlers")
272+
log.Printf("[DEBUG] Access id belongs to internal crawlers")
273273
}
274274
currentClientAccess = internalCrawlersAccess
275275
currentClientAccess.dataSource = dataSource
276276
} else if accessIdCache.FindAccessIdInCache(accessID) != "" {
277277
if stateCLI.enableDebugFlag {
278-
log.Printf("Access id found in cache")
278+
log.Printf("[DEBUG] Access id found in cache")
279279
}
280280
currentClientAccess = accessIdCache.accessIds[accessID]
281281
currentClientAccess.dataSource = dataSource
282282
accessIdCache.UpdateAccessIdAtCache(accessID, dataSource)
283283
} else {
284284
if stateCLI.enableDebugFlag {
285-
log.Printf("New access id, looking at Brood resources")
285+
log.Printf("[DEBUG] New access id, looking at Brood resources")
286286
}
287287
resources, err := bugoutClient.Brood.GetResources(
288288
NB_CONTROLLER_TOKEN,

nodes/node_balancer/cmd/nodebalancer/routes.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ func lbJSONRPCHandler(w http.ResponseWriter, r *http.Request, blockchain string,
114114
cpool.AddClientNode(currentClientAccess.AccessID, node)
115115
}
116116

117+
if stateCLI.enableDebugFlag {
118+
log.Printf("[DEBUG] Used node with endpoint: %s, call counter equals: %d", node.Endpoint, node.CallCounter)
119+
}
120+
117121
switch {
118122
case currentClientAccess.dataSource == "blockchain":
119123
if currentClientAccess.BlockchainAccess == false {

0 commit comments

Comments
 (0)