mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-14 08:57:14 +00:00
0a7f16a332
* Enhanced peer-ex protocol - added rate limiting, added response status and desc to the rpc * Better error result handling for PeerEx request, adjusted tests * Refactored RateLimit configuration option for better CLI UX - now possible to set separate limits per protocol. Adjusted mountings. Added and adjusted tests * Fix libwaku due to changes of error return type of fetchPeerExchangePeers * Fix rate limit setting tests due to changed defaults * Introduce new gauge to help dasboard effectively show current rate limit applied for protocol * Adjust timeing in filter rate limit test to let macos CI test run ok. * Address review findings, namings, error logs, removed left-overs * Changes to reflect latest spec agreement and changes. PeerExchange RPC is changed the now respond structure will contain status_code and status_desc.
20 lines
673 B
Nim
20 lines
673 B
Nim
{.push raises: [].}
|
|
|
|
import std/options
|
|
import metrics, setting
|
|
|
|
declarePublicGauge waku_service_requests_limit,
|
|
"Applied rate limit of non-relay service", ["service"]
|
|
|
|
declarePublicCounter waku_service_requests,
|
|
"number of non-relay service requests received", ["service", "state"]
|
|
|
|
declarePublicCounter waku_service_network_bytes,
|
|
"total incoming traffic of specific waku services", labels = ["service", "direction"]
|
|
|
|
proc setServiceLimitMetric*(service: string, limit: Option[RateLimitSetting]) =
|
|
if limit.isSome() and not limit.get().isUnlimited():
|
|
waku_service_requests_limit.set(
|
|
limit.get().calculateLimitPerSecond(), labelValues = [service]
|
|
)
|