Example #1
0
def app(gremlin_host, gremlin_port, event_loop, provider, aliases):
    app = event_loop.run_until_complete(
        Goblin.open(event_loop, provider=provider, aliases=aliases, hosts=[gremlin_host],
                    port=gremlin_port))

    app.register(Person, Place, Knows, LivesIn)
    return app
 def connect(self):
     """Connect to a graph database via a websocket, use GraphSONSerializersV2d0."""
     loop = asyncio.get_event_loop()
     self.app = loop.run_until_complete(
         Goblin.open(loop,
                     get_hashable_id=_get_hashable_id,
                     hosts=self.hosts,
                     port=self.port,
                     serializer=self.serializer))
     self.app.register(*tuple(ALL_MODELS))
 def __init__(self):
     loop = asyncio.get_event_loop()
     self.val = Goblin.open(loop,
                            hosts=[Configuration.JANUSGRAPH_DB_SERVER],
                            port=Configuration.JANUSGRAPH_DB_PORT,
                            scheme=Configuration.JANUSGRAPH_DB_SCHEMA)
    #Use the value "as-is" by default.
    result = val
    if isinstance(val, dict) and "@type" in val and "@value" in val:
        if val["@type"] == "janusgraph:RelationIdentifier":
            result = val["@value"]["value"]
    return result


#eader = graphson.GraphSONReader({'g:Date': DateDeserializer()})
#writer = graphson.GraphSONWriter({datetime.datetime: DateSerializer()})

#message_serializer = serializer.GraphSONMessageSerializer(reader=reader,
#                                                          writer=writer)

goblin_app = loop.run_until_complete(
    Goblin.open(loop, get_hashable_id=get_hashable_id))
#, message_serializer=message_serializer))

#goblin_app = loop.run_until_complete(Goblin.open(loop,
#                                                 hosts = ['localhost'],
#                                                 port = '8182',
#                                                 scheme = 'ws'))

#list_of_vertices = Goblin.vertices

goblin_app.register(User, Environment, Session, Browser, Device, OS, BelongsTo,
                    CompatibleWith, AssignedTo, LogsIn, InstanceOf, ViewedOn,
                    Exits, Accesses, Application, ApplicationInstance, Screen,
                    ScreenInstance, Tenant, Company, CloudSuite, Launches,
                    Enters, LogsOut, TimesOut, ConnectedWith, Operates, Hosts,
                    Provisioned, Supports, RunsOn, Owns, Implemnts,
Example #5
0
from zrpc import rpc
from zrpc import worker

from smoke_test import constants, models

logger = logging.getLogger(__name__)

logging.basicConfig(format=constants.LOG_FORMAT,
                    datefmt=constants.LOG_DATE_FORMAT,
                    level=logging.DEBUG)

# Setup
loop = zmq_asyncio.ZMQEventLoop()
asyncio.set_event_loop(loop)

app = loop.run_until_complete(Goblin.open(loop))
app.register(models.Node, models.Edge)

cluster = app._cluster


# Service RPC method defintions
async def echo(request, response):
    response.write_final(request)


async def yield_edge(request, response):
    async with aiohttp.ClientSession(loop=loop) as client:
        edge = await client.get('http://localhost:8080/')
        payload = await edge.read()
        logger.info(payload)