use throttle from config

This commit is contained in:
Annika Hannig 2023-05-26 11:51:52 +02:00
parent ac5b8b8287
commit 65f5edc83b
No known key found for this signature in database
GPG Key ID: 62E226E47DDCE58D
2 changed files with 5 additions and 1 deletions

View File

@ -20,4 +20,6 @@ type Config struct {
AltPipeProtocolPrefix string `ini:"alt_pipe_protocol_prefix"`
AltPipeProtocolSuffix string `ini:"alt_pipe_protocol_suffix"`
NeighborsRefreshTimeout int `ini:"neighbors_refresh_timeout"`
StreamParserThrottle int
}

View File

@ -16,6 +16,8 @@ func parseRoutesResponseStream(
meta := &api.Meta{}
routes := api.Routes{}
throttle := time.Duration(config.StreamParserThrottle) * time.Nanosecond
for {
t, err := dec.Token()
if err == io.EOF {
@ -68,7 +70,7 @@ func parseRoutesResponseStream(
}
// Wait a bit, so our CPUs do not go up in flames.
time.Sleep(30000 * time.Nanosecond)
time.Sleep(throttle)
route := parseRouteData(rdata, config, false)
routes = append(routes, route)