Make polling interval configurable
This commit is contained in:
parent
beac903a3f
commit
3a76fa74f1
|
@ -99,7 +99,8 @@ type
|
|||
PollingSubscriptions = ref object of JsonRpcSubscriptions
|
||||
|
||||
proc new*(_: type JsonRpcSubscriptions,
|
||||
client: RpcHttpClient): JsonRpcSubscriptions =
|
||||
client: RpcHttpClient,
|
||||
pollingInterval = 4.seconds): JsonRpcSubscriptions =
|
||||
|
||||
let subscriptions = PollingSubscriptions(client: client)
|
||||
|
||||
|
@ -113,7 +114,7 @@ proc new*(_: type JsonRpcSubscriptions,
|
|||
while true:
|
||||
for id in toSeq subscriptions.callbacks.keys:
|
||||
await poll(id)
|
||||
await sleepAsync(1.seconds)
|
||||
await sleepAsync(pollingInterval)
|
||||
except CancelledError:
|
||||
raise
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ suite "HTTP polling subscriptions":
|
|||
setup:
|
||||
client = newRpcHttpClient()
|
||||
await client.connect("http://localhost:8545")
|
||||
subscriptions = JsonRpcSubscriptions.new(client)
|
||||
subscriptions = JsonRpcSubscriptions.new(client,
|
||||
pollingInterval = 100.millis)
|
||||
|
||||
subscriptionTests(subscriptions, client)
|
||||
|
|
Loading…
Reference in New Issue