datastore-scala

Google Cloud Datastore client library

License

License

Categories

Categories

Scala Languages Data
GroupId

GroupId

com.ismetozozturk
ArtifactId

ArtifactId

datastore-scala_2.13
Last Version

Last Version

0.1.4
Release Date

Release Date

Type

Type

jar
Description

Description

datastore-scala
Google Cloud Datastore client library
Project URL

Project URL

https://github.com/iozozturk/datastore-scala
Project Organization

Project Organization

ismetozozturk
Source Code Management

Source Code Management

https://github.com/iozozturk/datastore-scala.git

Download datastore-scala_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/com.ismetozozturk/datastore-scala_2.13/ -->
<dependency>
    <groupId>com.ismetozozturk</groupId>
    <artifactId>datastore-scala_2.13</artifactId>
    <version>0.1.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.ismetozozturk/datastore-scala_2.13/
implementation 'com.ismetozozturk:datastore-scala_2.13:0.1.4'
// https://jarcasting.com/artifacts/com.ismetozozturk/datastore-scala_2.13/
implementation ("com.ismetozozturk:datastore-scala_2.13:0.1.4")
'com.ismetozozturk:datastore-scala_2.13:jar:0.1.4'
<dependency org="com.ismetozozturk" name="datastore-scala_2.13" rev="0.1.4">
  <artifact name="datastore-scala_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.ismetozozturk', module='datastore-scala_2.13', version='0.1.4')
)
libraryDependencies += "com.ismetozozturk" % "datastore-scala_2.13" % "0.1.4"
[com.ismetozozturk/datastore-scala_2.13 "0.1.4"]

Dependencies

compile (10)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.0
com.thesamet.scalapb : scalapb-runtime_2.13 jar 0.9.0
com.lightbend.akka.grpc : akka-grpc-runtime_2.13 jar 0.7.1
io.grpc : grpc-stub jar 1.22.1
org.scala-lang : scala-reflect jar 2.13.0
com.typesafe.akka : akka-stream_2.13 jar 2.5.23
com.typesafe.akka : akka-slf4j_2.13 jar 2.5.23
ch.qos.logback : logback-classic jar 1.2.3
io.grpc : grpc-auth jar 1.23.0
com.google.auth : google-auth-library-oauth2-http jar 0.17.0

provided (1)

Group / Artifact Type Version
org.mortbay.jetty.alpn : jetty-alpn-agent jar 2.0.9

test (3)

Group / Artifact Type Version
org.scalatest : scalatest_2.13 jar 3.0.8
com.typesafe.akka : akka-stream-testkit_2.13 jar 2.5.23
org.mockito : mockito-core jar 3.0.0

Project Modules

There are no modules declared in this project.

Google Cloud Datastore Scala client

True asynchronous and non-blocking Scala client library for Google Cloud Datastore with gRPC backend.

Features

  • Insert, Update, Delete, Query, Lookup, HealthCheck operations
  • All operations are asynchronous and non blocking
  • Connections are handled in HTTP/2 gRPC layer
  • Transactional by default
  • All fields are indexed
  • Automatic class to entity, entity to class resolution
  • Configurations can be overridden on demand
  • Supports Scala 2.13

Overview

Current implementations of Google Cloud Datastore Java client library and other custom implementations found on Github are synchronous and blocking. This creates performance issues at scale. This library use Datastore Proto files and gRPC as backend so that all communication layer is async and return Future. Also relevant Datastore classes are created from official Google Cloud Datastore Proto files to be consistent and provides easy migration in future.

Usage

Simply add library as a dependency.

libraryDependencies ++= Seq(
  "com.ismetozozturk" %% "datastore-scala" % "0.1.4"
)

Example: Insert

Extend your classes from BaseEntity and override kind and id attributes.

  case class User(name: String, age: Int) extends BaseEntity {
    override def id: Any = name

    override def kind: String = "users"
  }

  val user = User("ismet", 35)

  val userRepository = DatastoreRepository[User]()

  val userF: Future[User] = userRepository.insert(user)

Example: Query

Use native Query classes coming from Google Cloud Datastore to write your queries. For lookups based on Ids, use get and getMany methods from this library.

  val userRepository = DatastoreRepository[User]()

  val userF: Future[Seq[User]] = userRepository.runQuery(Query(kind = Seq(KindExpression("users"))))

Example: HealthCheck

For implementing you service healthchecks, you can use healthcheck method from this library to check if you can access datastore.

  val datastoreHealth: Future[Boolean] = repositoryInTest.healthCheck()

Check Integration Tests and Unit Tests for further library documentation.

Running Tests

To run unit tests simply run:

sbt test

Integration test setup include datastore emulator as well. To run integration tests run:

sbt 'dockerComposeTest it:test'

TODO

  • excludeFromIndex support
  • transactional and non-transactional commit support
  • handle array types
  • travis build, test
  • support for auto generated ids, currently only custom keys supported
  • get rid of default instance creation, blocks require statements in classes
  • support for multiple ops per transaction
  • count docs support

Versions

Version
0.1.4
0.1.3