def handle_up_time(): """ Handle a up time request. NOTE: This method makes a blocking call to the DataGovernanceSystem actor. """ gov = named_actors.get_actor(dgs_server_name) up_time = ray.get(gov.get_up_time.remote()) return json.dumps({'up_time': up_time})
def handle_reset(): """ Handle a reset request. NOTE: This method makes a "fire and forget", non-blocking call to the DataGovernanceSystem actor. """ gov = named_actors.get_actor(dgs_server_name) gov.reset.remote() return json.dumps({'message': 'async reset invoked.'})
def handle_get_ids(): """ Returns the logged ids, which could be huge! NOTE: This method makes a blocking call to the DataGovernanceSystem actor. """ gov = named_actors.get_actor(dgs_server_name) ids = ray.get(gov.get_ids.remote()) return json.dumps({'ids': ids})
def handle_get_count(): """ Returns the count of logged ids. NOTE: This method makes a blocking call to the DataGovernanceSystem actor. """ gov = named_actors.get_actor(dgs_server_name) count = ray.get(gov.get_count.remote()) return json.dumps({'count': count})
def handle_log(request): """Handler for logging ids.""" gov = named_actors.get_actor(dgs_server_name) record_id = request.args.get('id', None) if not record_id: raise Exception( f'Invalid "log" request, missing id. Request = {request}') else: gov.log.remote(record_id) # fire and forget return json.dumps( {'message': f'sent async log request for {record_id}'})