Gracefully report backend failure to connect
This commit is contained in:
parent
b460313bc8
commit
406e96ce39
18
main.py
18
main.py
@ -53,14 +53,18 @@ def application():
|
|||||||
@app.post('/v1/vista')
|
@app.post('/v1/vista')
|
||||||
def cb_connect():
|
def cb_connect():
|
||||||
params = request.json['params']
|
params = request.json['params']
|
||||||
if params.get('secret') == secret:
|
try:
|
||||||
cid = ''.join(secrets.choice(string.ascii_lowercase + string.digits) for i in range(64))
|
if params.get('secret') == secret:
|
||||||
while cid in clients:
|
|
||||||
cid = ''.join(secrets.choice(string.ascii_lowercase + string.digits) for i in range(64))
|
cid = ''.join(secrets.choice(string.ascii_lowercase + string.digits) for i in range(64))
|
||||||
clients[cid] = client = CacheProxyRPC(rpc.ClientSync(host=params.get('host', 'test.northport.med.va.gov'), port=int(params.get('port', 19009))))
|
while cid in clients:
|
||||||
return jsonify({ 'result': cid, 'error': None, 'id': request.json.get('id') })
|
cid = ''.join(secrets.choice(string.ascii_lowercase + string.digits) for i in range(64))
|
||||||
else:
|
clients[cid] = client = CacheProxyRPC(rpc.ClientSync(host=params.get('host', 'test.northport.med.va.gov'), port=int(params.get('port', 19009))))
|
||||||
return jsonify({ 'result': None, 'error': { 'type': 'Unauthorized', 'args': [] }, 'id': request.json.get('id') })
|
return jsonify({ 'result': cid, 'error': None, 'id': request.json.get('id') })
|
||||||
|
else:
|
||||||
|
return jsonify({ 'result': None, 'error': { 'type': 'Unauthorized', 'args': [] }, 'id': request.json.get('id') })
|
||||||
|
except Exception as ex:
|
||||||
|
logger.exception(request.url)
|
||||||
|
return jsonify({ 'result': None, 'error': { 'type': ex.__class__.__name__, 'args': ex.args }, 'id': request.json.get('id') })
|
||||||
|
|
||||||
@app.post('/v1/vista/<cid>/close')
|
@app.post('/v1/vista/<cid>/close')
|
||||||
def cb_close(cid):
|
def cb_close(cid):
|
||||||
|
Loading…
Reference in New Issue
Block a user