mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
add another field to status api and service registry, "threads", the size of the proxy server thread pool
This commit is contained in:
parent
35d7ccd12e
commit
f17584836e
2
setup.py
2
setup.py
@ -51,7 +51,7 @@ except:
|
||||
|
||||
setuptools.setup(
|
||||
name='warcprox',
|
||||
version='2.1b1.dev64',
|
||||
version='2.1b1.dev65',
|
||||
description='WARC writing MITM HTTP/S proxy',
|
||||
url='https://github.com/internetarchive/warcprox',
|
||||
author='Noah Levitt',
|
||||
|
@ -1285,32 +1285,35 @@ def test_status_api(warcprox_):
|
||||
url = 'http://localhost:%s/status' % warcprox_.proxy.server_port
|
||||
response = requests.get(url)
|
||||
assert response.status_code == 200
|
||||
response_dict = json.loads(response.content.decode('ascii'))
|
||||
assert set(response_dict.keys()) == {
|
||||
status = json.loads(response.content.decode('ascii'))
|
||||
assert set(status.keys()) == {
|
||||
'role', 'version', 'host', 'address', 'port', 'pid', 'load',
|
||||
'queued_urls', 'queue_max_size', 'seconds_behind'}
|
||||
assert response_dict['role'] == 'warcprox'
|
||||
assert response_dict['version'] == warcprox.__version__
|
||||
assert response_dict['port'] == warcprox_.proxy.server_port
|
||||
assert response_dict['pid'] == os.getpid()
|
||||
'queued_urls', 'queue_max_size', 'seconds_behind', 'threads'}
|
||||
assert status['role'] == 'warcprox'
|
||||
assert status['version'] == warcprox.__version__
|
||||
assert status['port'] == warcprox_.proxy.server_port
|
||||
assert status['pid'] == os.getpid()
|
||||
assert status['threads'] == warcprox_.proxy.pool._max_workers
|
||||
|
||||
def test_svcreg_status(warcprox_, service_registry):
|
||||
if service_registry:
|
||||
start = time.time()
|
||||
while time.time() - start < 15:
|
||||
svc = service_registry.available_service('warcprox')
|
||||
if svc:
|
||||
status = service_registry.available_service('warcprox')
|
||||
if status:
|
||||
break
|
||||
time.sleep(0.5)
|
||||
assert svc
|
||||
assert set(svc.keys()) == {
|
||||
assert status
|
||||
assert set(status.keys()) == {
|
||||
'id', 'role', 'version', 'host', 'port', 'pid', 'load',
|
||||
'queued_urls', 'queue_max_size', 'seconds_behind',
|
||||
'first_heartbeat', 'heartbeat_interval', 'last_heartbeat'}
|
||||
assert svc['role'] == 'warcprox'
|
||||
assert svc['version'] == warcprox.__version__
|
||||
assert svc['port'] == warcprox_.proxy.server_port
|
||||
assert svc['pid'] == os.getpid()
|
||||
'first_heartbeat', 'heartbeat_interval', 'last_heartbeat',
|
||||
'threads'}
|
||||
assert status['role'] == 'warcprox'
|
||||
assert status['version'] == warcprox.__version__
|
||||
assert status['port'] == warcprox_.proxy.server_port
|
||||
assert status['pid'] == os.getpid()
|
||||
assert status['threads'] == warcprox_.proxy.pool._max_workers
|
||||
|
||||
def test_timestamped_queue():
|
||||
# see also test_queue.py
|
||||
|
@ -149,6 +149,7 @@ class WarcproxController(object):
|
||||
status_info['queued_urls'] = self.proxy.recorded_url_q.qsize()
|
||||
status_info['queue_max_size'] = self.proxy.recorded_url_q.maxsize
|
||||
status_info['seconds_behind'] = self.proxy.recorded_url_q.seconds_behind()
|
||||
status_info['threads'] = self.proxy.pool._max_workers
|
||||
|
||||
self.status_info = self.service_registry.heartbeat(status_info)
|
||||
self.logger.log(
|
||||
|
@ -213,6 +213,7 @@ class WarcProxyHandler(warcprox.mitmproxy.MitmProxyHandler):
|
||||
'queue_max_size': self.server.recorded_url_q.maxsize,
|
||||
'seconds_behind': self.server.recorded_url_q.seconds_behind(),
|
||||
'pid': os.getpid(),
|
||||
'threads': self.server.pool._max_workers,
|
||||
}
|
||||
payload = json.dumps(
|
||||
status_info, indent=2).encode('utf-8') + b'\n'
|
||||
|
Loading…
x
Reference in New Issue
Block a user