Skip to content

Gremlin-Server client with ad-hoc extensible, reactive, typeclass based API allowing for using turing complete graph traversal language gremlin to query graph databases from browser

Branch: master
Go to file
Code

Latest commit

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

scalajs-gremlin-client

Legacy software - due to discontinued reactive-websocket and too big Monix breaking changes

Allows your browser applications to communicate with Gremlin Server via reactive-websocket thanks to Monix and uPickle.

  • dependency : "com.pragmaxim" %%% "scalajs-gremlin-client" % "0.0.4-SNAPSHOT"
  • Scala.js version : 0.6.31

Mainly it approaches :

  • gremlin's turing completeness by letting its users deal with it themselves in their application, thanks to Scala's Type Classes and excellent serialization library uPickle. Any new type of response might be added by user himself in his application by adding an evidence for a Reader type class like this. Found a new kind of response/request? Add it to your app and submit a feature request :-)
  • gremlin server response streaming which is handled the Rx way thanks to the awesome Monix project

Testing

This expects gremlin-sever be already running, please see sbt settings :

> js/fastOptStage::test

This starts gremlin-server before running a test suite if you have gremlinServerHome set up correctly :

> js/test

Usage

// requests are built using js.Dynamic literals 
lit(
  EvalOp,
  DefaultProc,
  Args(
    lit(
      GremlinArg("g.v(1)"),
      BatchSizeArg(20),
      LangArg("gremlin-groovy")
    )
  )
)

// import all types or just those that you'll need
 import com.pragmaxim.gremlin.client._

// connect to server
val client = GremlinClient(Url(WS, "localhost", 8182, Option.empty))

// sending a request requires specifying return type information to satisfy uPickle's Reader TypeClass. 
// You'll get strongly typed result in return...
val observable = client.send[Vector[Vertex]](query)

// do all kinds of Rx operations 
observable.map(...).filter(...).foreach(...) 
  • Observable contains only responses corresponding to particular requestId, so you don't need to worry about that
  • Please see GremlinClientSuite as a source of inspiration
  • As gremlin language is turing complete, it is inevitable that you'll find new and new return types that are not supported. In that case you need to add corresponding uPickle Reader to Implicits

NOTE :

  • Just the basic operations are implemented and tested so far - but it is expected that adding new operations will mostly consist in adding a TypeClass evidence
  • Tests work on real operating systems only, some additional work required on MS Windows
  • Requires java 8, as gremlin-server does

About

Gremlin-Server client with ad-hoc extensible, reactive, typeclass based API allowing for using turing complete graph traversal language gremlin to query graph databases from browser

Topics

Resources

License

Releases

No releases published

Languages

You can’t perform that action at this time.