Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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"
Ejemplo n.º 3
0
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"
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
 def setUp(self):
     self.session = cql.session()
     models.init(self.session)
Ejemplo n.º 6
0
def migrate():
    sess = cql.session()
    models.init(sess)
Ejemplo n.º 7
0
 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)])
Ejemplo n.º 8
0
 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)])