mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
support calling ServiceRegistry.available_services() with no arguments to get all available services (services with a recent heartbeat)
This commit is contained in:
parent
7a8963b7c4
commit
92b8007f98
@ -174,11 +174,15 @@ class ServiceRegistry(object):
|
||||
except r.ReqlNonExistenceError:
|
||||
return None
|
||||
|
||||
def available_services(self, role):
|
||||
def available_services(self, role=None):
|
||||
try:
|
||||
result = self.r.table('services').filter({"role":role}).filter(
|
||||
query = self.r.table('services')
|
||||
if role:
|
||||
query = query.filter({"role":role})
|
||||
query = query.filter(
|
||||
lambda svc: r.now().sub(svc["last_heartbeat"]) < 3 * svc["heartbeat_interval"] #.default(20.0)
|
||||
).order_by("load").run()
|
||||
).order_by("load")
|
||||
result = query.run()
|
||||
return result
|
||||
except r.ReqlNonExistenceError:
|
||||
return []
|
||||
|
Loading…
x
Reference in New Issue
Block a user