All Projects → coreyauger → reactive-gremlin

coreyauger / reactive-gremlin

Licence: MIT License
akka http gremlin 3 websocket connector

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to reactive-gremlin

janusgraph-docker
Yet another JanusGraph, Cassandra/Scylla and Elasticsearch in Docker Compose setup
Stars: ✭ 54 (+68.75%)
Mutual labels:  graph-database, titan
mizo
Super-fast Spark RDD for Titan Graph Database on HBase
Stars: ✭ 24 (-25%)
Mutual labels:  graph-database, titan
liquigraph
Migrations for Neo4j
Stars: ✭ 122 (+281.25%)
Mutual labels:  graph-database
akka-streams-example
Example on Akka Streams with productive cases
Stars: ✭ 20 (-37.5%)
Mutual labels:  akka-streams
Titan
A free, advanced CS:GO report and commendation bot built with performance and ease-of-use in mind
Stars: ✭ 210 (+556.25%)
Mutual labels:  titan
semagrow
A SPARQL query federator of heterogeneous data sources
Stars: ✭ 27 (-15.62%)
Mutual labels:  graph-database
akka-http-streaming-response-examples
A list of examples that involve streaming with Akka Streams and used together with Akka HTTP
Stars: ✭ 73 (+128.13%)
Mutual labels:  akka-streams
Akka
Examples and explanations of how Akka toolkit works
Stars: ✭ 20 (-37.5%)
Mutual labels:  akka-streams
seabolt
Neo4j Bolt Connector for C
Stars: ✭ 37 (+15.63%)
Mutual labels:  graph-database
mage
MAGE - Memgraph Advanced Graph Extensions 🔮
Stars: ✭ 89 (+178.13%)
Mutual labels:  graph-database
jnosql.github.io
The JNoSQL is a framework whose has the goal to help Java developers to create Java EE applications with NoSQL, whereby they can make scalable application beyond enjoy the polyglot persistence.
Stars: ✭ 13 (-59.37%)
Mutual labels:  graph-database
laravel-arangodb
ArangoDB driver for Laravel
Stars: ✭ 43 (+34.38%)
Mutual labels:  graph-database
NeoClient
🦉 Lightweight OGM for Neo4j which support transactions and BOLT protocol.
Stars: ✭ 21 (-34.37%)
Mutual labels:  graph-database
GraphDBLP
a Graph-based instance of DBLP
Stars: ✭ 33 (+3.13%)
Mutual labels:  graph-database
simplegraphdb
Basic Golang implementation of a Triple Store. Built to learn the Golang language before an internship.
Stars: ✭ 17 (-46.87%)
Mutual labels:  graph-database
boltex
Elixir driver for the neo4j bolt protocol
Stars: ✭ 27 (-15.62%)
Mutual labels:  graph-database
typedb
TypeDB: a strongly-typed database
Stars: ✭ 3,152 (+9750%)
Mutual labels:  graph-database
akka-http-circe-json-template
Akka HTTP REST API Project Template using Akka HTTP 10.0.4 with Circe 0.7.0 targeting Scala 2.12.x
Stars: ✭ 21 (-34.37%)
Mutual labels:  akka-streams
thoth
Event sourcing in java with vavr, akka stream and vertx reactive PG driver
Stars: ✭ 27 (-15.62%)
Mutual labels:  akka-streams
vor-knowledge-graph
🎓 Open knowledge mining and graph builder
Stars: ✭ 57 (+78.13%)
Mutual labels:  graph-database

reactive-gremlin

High throughput akka http gremlin 3 websocket connector with backpressure.

High Flow Gremlin .... Blows your hair back !

gremlin

What is reactive-gremlin

reactive-gremlin is a streaming websocket client that connects to a gremlin server to execute gremlin scripts. Current client including the Java client provided by datastax have the capability to crash your gremlin server by overflowing the server with asyn requests. Your gremlin server will buffer incoming requests and service them when it has finished the ones in the queue. For fast consumers (bulk loaders) it is possible to cause Out of memory Exceptions and crash the server.

reactive-gremlin provides a way around this by implementing backpressure through a side channel. This will slow down the fast consumer while the server is overloaded and speed it up when the server catches up. It does this throw a user controlled parameter on the maximum in-flight calls allowed to any one server. The stream monitors responses from the server and controlls backpressure on the stream accordingly.

Build.sbt

Add the following dependency to your porject.

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

"io.surfkit" %% "reactive-gremlin" % "0.0.1"

Usage

scripts

I have provided a simple builder to convert you gremlin scripts into the required types for transport. Here are some examples of encoding a few gremlin groovy scripts

val simple = GremlinClient.buildRequest("g.V().has('email','[email protected]').has('is_douchebag','true').valueMap();")
val create = GremlinClient.buildRequest("graph.addVertex(label, 'entity','uri','https://en.wikipedia.org/wiki/Donald_Trump');")

client

To issue request to your server you must create a GremlinClient. Parameters:

  • host: String is the websocket url to connect to your server (default localhost:8182).
  • maxInFlight:Int controls the max number of request that you will allow you server to process at one time (default 250)
  • responder:Option[ActorRef] an optional Akka actor that will receive Gremlin.Response messages.
  • onResponse:Option[Gremline.Response => Unit] an optional callback that will receive Gremlin.Response messages.
val gclient = new GremlinClient(host="ws://localhost:8182",maxInFlight=100)

pushing data

There are 3 ways to push your request data into the flow:

  • as a driver that will return a Future
  • via ActorRef publisher (usefull for standard interaction with your gremlin server)
  • via Flow[GremlinRequest, _] flow that you create from another Source. This is extreamly usfull when bulk loading data from a file or other source. More on this below.

driver returning a future example

val gclient = new GremlinClient(host="ws://localhost:8182",maxInFlight=100)
gclient.query("g.V().has('email','[email protected]').has('is_douchebag','true').valueMap();")
       .map{ x: Gremlin.Response =>
          val json: Option[List[JsValue]] = x.result.data
          ...
       }

actor push example

Here is a simple but full example of how to use the client

def response(res:Gremlin.Response):Unit = {
  println(s"The response is ${res}")
}

val gclient = new GremlinClient(host="ws://localhost:8182",maxInFlight=100, onResponse = Some(response))
val producer = gclient.connectActor

val simple = GremlinClient.buildRequest("g.V().has('email','[email protected]').has('is_douchebag','true').valueMap();")
val create = GremlinClient.buildRequest("graph.addVertex(label, 'entity','uri','https://en.wikipedia.org/wiki/Donald_Trump');")

producer ! simple
producer ! create

flow example

Here is a file streaming example (bulk loader)

def response(res:Gremlin.Response):Unit = {
  println(s"The response is ${res}")
}

val gclient = new GremlinClient(host="ws://localhost:8182",maxInFlight=100, onResponse = Some(response))

val csv = new File("/path/to/csv")
val flow = FileIO.fromFile(outFile)
          .via(Framing.delimiter(
            ByteString("\n"),
            maximumFrameLength = 1000000,
            allowTruncation = false))
          .map(_.utf8String)
          .mapConcat{ line =>
            // parse and form some gremlin groove insert script
            // we call that `gscript`
            GremlinClient.buildRequest(gscript)
          }
          
gclient.connectFlow(flow)   // connect and run graph
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].