def main(): tracer.instance(routes.app) sess = cql.session() models.init(sess) view = graphql.GraphQLView.as_view('graphql', schema=schema.schema, middleware=[tracer.middleware], graphiql=True, graphiql_template=schema.HTML) routes.app.add_url_rule("/graphql", view_func=view) routes.app.run(use_reloader=True, threaded=True)
def healthz(): """ healthz is a monitoring end-point used to verify the node is available to serve traffic. :return: 200 OK if all dependencies are reachable, otherwise status is 500. """ error = cql.ping(cql.session()) if error is not None: flask.abort(500) return "OK"
def isready(): """ isready is a monitoring end-point used to verify that the node is ready to be placed in balance after start-up. :return: 200 OK if all dependencies are reachable, otherwise status is 500. """ error = cql.ping(cql.session()) if error is not None: flask.abort(500) return "OK"
def info(): """ info is a monitoring end-point that outputs JSON including the hostname, connection errors, and any relevant metadata. metadata MUST NOT include secrets or credentials. :returns: JSON data for this services configuration details and errors. """ errors = [] metadata = { "cassandra_hosts": cql.hosts(app) } ping_error = cql.ping(cql.session()) if ping_error is not None: errors.append(ping_error) return flask.jsonify(hostname=socket.gethostname(), metadata=metadata, errors=errors)
def setUp(self): self.session = cql.session() models.init(self.session)
def migrate(): sess = cql.session() models.init(sess)
def batch_load_fn(self, keys): # pylint: disable=E0202 with span('specie', {'count': len(keys), 'ids': keys}): return promise.Promise.resolve([map2specie(m) for m in cql.species(cql.session(), keys)])
def batch_load_fn(self, keys): # pylint: disable=E0202 with span('character', {'count': len(keys), 'ids': keys}): return promise.Promise.resolve([map2character(c) for c in cql.people(cql.session(), keys)])