• Stars
    star
    15
  • Rank 1,322,808 (Top 27 %)
  • Language
    Scala
  • Created almost 8 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Neo4j Scala client using Akka-Http

neo4akka

Codacy Badge Build Status Stories in Ready Gitter Maven Central

Neo4j client for Scala using Akka-Http

All existing Scala clients try to be too clever adding obfuscation on top of the communication, creating a limiting DSL, or not using true non-blocking communication.

At its core this client will attempt to be a very clean and representative client allowing full use of Neo4j with Akka-Http in an entirely non-blocking way while still remaining true to the Cypher query language.

Status

Fully functional API that supports the majority of use-cases but ongoing development is still happening to make it more useful and convenient.

Features for 1.0.0

  • Asynchronous, true non-blocking IO with Akka HTTP
  • Cypher String Interpolator
  • Cypher Query Parser
  • Cypher Query Parser via Macro on Interpolation at compile-time
  • Structured QueryResponse
  • Macro support for extracting case class from QueryResponse

Features for 1.1.0

  • Insert and update from case class into database
  • Transactions
  • Practical Pagination support

Documentation

In desperate need of help. For now just look at the tests until we can get the first release finished.

Setup

neo4akka is published to Sonatype OSS and Maven Central and supports JVM with 2.11 and 2.12:

libraryDependencies += "com.outr" %% "neo4akka" % "1.0.1"

Using

Imports

The only import necessary to use neo4akka is the following import along with an execution context for futures:

import com.outr.neo4akka._

import scala.concurrent.ExecutionContext.Implicits.global

Creating a Session

Supply the host, port, and credentials to validate and establish a session with neo4j:

val sessionFuture[Future[Neo4Akka]] = Neo4Akka("localhost", 7474, "neo4j", "password")

Creating a Query

With neo4akka's powerful Cypher language interpolation (uses neo4j's built-in query validation) we can create compile-time validated Cypher queries with ease:

val name = "Tom Hanks"
val query = cypher"MATCH (p: Person {name: $name}) RETURN p"

If the query is malformed compilation will fail and injected arguments are properly assigned to the argument list for sending to the database as unique arguments.

Executing a Query

Since our Neo4Akka instance may or may not have completed yet, we can flatMap the Future in order to execute the query against the database and get back a Future[ResultSet]. For the purposes of this example, we'll simply do a blocking Await to get the ResultSet:

val resultSetFuture[Future[ResultSet]] = sessionFuture.flatMap(session => session(query))
val resultSet: ResultSet = Await.result(request, Duration.Inf)

Processing Results

Now that we have a ResultSet we can access the return p from our query by name and use a compile-time Macro to populate a case class Person with the values:

case class Person(name: String, born: Int)

val people: Vector[Person] = resultSet("p")[Person]

Disposing

Because neo4akka uses Akka Actors internally, it must be properly disposed to release the ActorSystem and ActorMaterializer.

Note: An instance of Neo4Akka uses Akka HTTP for true asynchronous non-blocking IO, so there is no state or unsafe reference information stored in the session.

sessionFuture.map(_.dispose())

More Repositories

1

scribe

The fastest logging library in the world. Built from scratch in Scala and programmatically configurable.
Scala
502
star
2

youi

Next generation user interface and application development in Scala and Scala.js for web, mobile, and desktop.
Scala
209
star
3

reactify

The first and only true Functional Reactive Programming framework for Scala.
Scala
84
star
4

scarango

ArangoDB client written in Scala
Scala
59
star
5

scalarelational

Type-Safe framework for defining, modifying, and querying SQL databases
Scala
58
star
6

lucene4s

Light-weight convenience wrapper around Lucene to simplify complex tasks and add Scala sugar.
Scala
54
star
7

media4s

Scala command-line wrapper around ffmpeg, ffprobe, ImageMagick, and other tools relating to media.
Scala
33
star
8

perfolation

Performance focused interpolation
Scala
28
star
9

profig

Powerful configuration management for Scala (JSON, properties, command-line arguments, and environment variables)
Scala
28
star
10

sgine

Scala Engine for OpenGL-based Desktop, Android, and iOS game and business development.
Scala
22
star
11

mailgun4s

Mailgun API implementation in Scala
Scala
17
star
12

powerscala

Powerful framework providing many useful utilities and features on top of the Scala language.
Scala
15
star
13

scala-stripe

Complete Browser and Server client integration of Stripe in Scala and Scala.js
Scala
12
star
14

spice

Powerful client / server technology for Scala
Scala
8
star
15

jefe

Manages installation, updating, downloading, launching, error reporting, and more for your application.
Scala
8
star
16

googleapi.scala.js

Wrapper around Google APIs
Scala
6
star
17

scalajs-pixijs

Scala.js facade for Pixi.js
JavaScript
6
star
18

giant-scala

Advanced functionality for working with MongoDB in Scala
Scala
6
star
19

scalapass

Useful tools for managing storage and validation of passwords in Scala applications
Scala
5
star
20

pdf4s

Simplified wrapper to create PDFs in Scala
Scala
5
star
21

outrgl

DEPRECATED: Please use http://youi.io going forward
Scala
5
star
22

nextui

UI Abstraction Framework
Scala
4
star
23

pmc

Project Management in Code - An incredibly straight-forward project management and build tool for Scala.
Scala
4
star
24

youi-designer

User interface designer tool to create, edit, import, export, and generate user interfaces for youi.
Scala
4
star
25

youi-template

Infrastructure for working with existing HTML files.
Scala
4
star
26

uberzip

Very fast multi-threaded unzipping utility.
Scala
3
star
27

youi-example

Example application built on YouI
Scala
3
star
28

robobrowser

Headless Browser wrapper library providing lots of features for API-access
Scala
3
star
29

hyperscala

DEPRECATED - See https://github.com/outr/youi for something far better.
Scala
3
star
30

lightdb

Prototype database concept using Lucene and HaloDB
Scala
3
star
31

youi-plugin

SBT plugin for use with YouI projects
Scala
3
star
32

outrbackup

Multi-threaded backup system.
Scala
2
star
33

iconsole

Web-based terminal / console with modular integration and distributed connectivity
Scala
2
star
34

batcher

Command-line tool to batch operations, pause, save, and control concurrency
Scala
2
star
35

async

Scala and Scala.js framework to execute and schedule asynchronous tasks
Scala
2
star
36

jsdoc2scalajs

Automated conversion of JSDocs to Scala.js facades.
Scala
1
star
37

webmidi.scala.js

Scala.js facade for Web MIDI API and https://github.com/cwilso/WebMIDIAPIShim
Scala
1
star
38

scalarelational-manual

Source for generating the ScalaRelational manual
Scala
1
star
39

sgine-desktop.g8

Desktop-only template for Sgine
Scala
1
star
40

geoscala

Locational data index that is full-text searchable and can update itself. Complete geospatial sorting and filtering support.
Scala
1
star
41

jar-heaven

The final solution to JAR Hell
Scala
1
star
42

smartystreets-scala-sdk

Scala SDK for SmartyStreets (https://smartystreets.com)
Scala
1
star
43

torrent

Prototype for bittorrent management in Scala
Scala
1
star
44

scalajs-fabricjs

Facade around Fabric.js for Scala.js
Scala
1
star