mirror of
https://github.com/element-hq/synapse
synced 2024-09-06 03:00:05 +00:00
Allow clock to be passed in to func
This commit is contained in:
parent
f699b8f997
commit
f9d3665c88
1 changed files with 3 additions and 3 deletions
|
@ -155,10 +155,10 @@ class SRVClientEndpoint(object):
|
||||||
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def resolve_service(service_name, dns_client=client, cache=SERVER_CACHE):
|
def resolve_service(service_name, dns_client=client, cache=SERVER_CACHE, clock=time):
|
||||||
cache_entry = cache.get(service_name, None)
|
cache_entry = cache.get(service_name, None)
|
||||||
if cache_entry:
|
if cache_entry:
|
||||||
if all(s.expires > int(time.time()) for s in cache_entry):
|
if all(s.expires > int(clock.time()) for s in cache_entry):
|
||||||
servers = list(cache_entry)
|
servers = list(cache_entry)
|
||||||
defer.returnValue(servers)
|
defer.returnValue(servers)
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ def resolve_service(service_name, dns_client=client, cache=SERVER_CACHE):
|
||||||
port=int(payload.port),
|
port=int(payload.port),
|
||||||
priority=int(payload.priority),
|
priority=int(payload.priority),
|
||||||
weight=int(payload.weight),
|
weight=int(payload.weight),
|
||||||
expires=int(time.time()) + host_ttl,
|
expires=int(clock.time()) + host_ttl,
|
||||||
))
|
))
|
||||||
|
|
||||||
servers.sort()
|
servers.sort()
|
||||||
|
|
Loading…
Reference in a new issue