Skip to content

Commit

Permalink
Merge pull request #1 from vlmiroshnikov/writes
Browse files Browse the repository at this point in the history
Writes
  • Loading branch information
vlmiroshnikov authored Jan 27, 2018
2 parents 5d84ea3 + 46beaf3 commit fc3b537
Show file tree
Hide file tree
Showing 31 changed files with 369 additions and 312 deletions.
8 changes: 4 additions & 4 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
style = defaultWithAlign

align.tokens = [off]
align.tokens = [{code = "=>", owner = "Case"}]
align.tokens = ["%", "%%"]
danglingParentheses = true
docstrings = JavaDoc
indentOperator = spray
docstrings = ScalaDoc
maxColumn = 120
rewrite.rules = [RedundantBraces, RedundantParens, SortImports]
rewrite.rules = [RedundantParens, SortImports]
unindentTopLevelOperators = true
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: scala
sudo: false

scala:
- "2.12.2"
- "2.12.4"

jdk:
- oraclejdk8
Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,52 @@ Aero [![travis-badge][]][travis]

This project provides scala client to Aerospike database.

Dependencies
------------
- scala 2.12
- shapeless-2.3.3
- java aerospike-client 4


Quick start
-----------
To start working with Aero you have to add dependency sbt:
```scala
libraryDependencies += "org.aero" % "aero" % "0.1.1"
```

Now you can use it like this:

```scala
import scala.concurrent.duration._
import org.aero.AeroOps._
import org.aero._

import scala.concurrent.Await
import scala.concurrent.ExecutionContext.Implicits.global

object Main {
def main(args: Array[String]): Unit = {
val host = "localhost"
val port = 3000

implicit val schema = Schema("test", "org-os")
implicit val ac = AeroClient(host, port)

val eventualUnit = for {
_ <- put("002", (WriteBin("key", "002"), WriteBin("string_column", "string"), WriteBin("double_column", 1.1)))
(key, value) <- get("002", ("key".as[String], "double_column".as[Double]))
optionResult <- getOpt("002", "string_column".as[String])
} yield {
println(s"$key = $value") // 002 = 1.1
println(optionResult) // Some(String)
}

Await.ready(eventualUnit, Duration.Inf)

ac.close()
}
}

```

22 changes: 13 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name := "aero"
import sbt.Keys._

version := "0.1"
scalaVersion := "2.12.3"
lazy val `aero` = project
.in(file("."))
.settings(
version := "0.1.1",
scalaVersion := "2.12.4",
scalacOptions := Settings.scalacOptions,
libraryDependencies ++= Settings.dependencies,


libraryDependencies ++= Seq(
"com.chuusai" %% "shapeless" % "2.3.2",
"com.aerospike" % "aerospike-client" % "4.0.8",
"com.typesafe.akka" %% "akka-stream" % "2.5.6"
)
organization := "org.aero",
bintrayRepository := "aero",
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
bintrayPackageLabels := Seq("scala", "aerospike")
)
31 changes: 31 additions & 0 deletions project/Settings.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sbt._

object Settings {

object Versions {
val shapless = "2.3.3"
val aerospike = "4.0.8"
}

val scalacOptions = Seq(
"-target:jvm-1.8",
"-encoding",
"UTF-8",
"-unchecked",
"-deprecation",
"-Xfuture",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Ywarn-unused"
)

val dependencies = Seq(
"com.chuusai" %% "shapeless" % Versions.shapless,
"com.aerospike" % "aerospike-client" % Versions.aerospike
)
}



2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.0.2
sbt.version = 1.1.0
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.2")
10 changes: 4 additions & 6 deletions src/main/scala/org/aero/AeroOps.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.aero

import org.aero.impl.reads.{DefaultUnmarshallers, ReadOps, ToNames}
import org.aero.impl.reads.streams.StreamedReadOps
import org.aero.impl.writes.WriteOps
import org.aero.common.DefaultKeyWrappers
import org.aero.writes._
import org.aero.reads._

object AeroOps extends WriteOps with ReadOps with ToNames with DefaultUnmarshallers

object AeroStreamedOps extends StreamedReadOps
object AeroOps extends WriteOps with ReadOps with ToNames with DefaultDecoders with DefaultEncoders with DefaultKeyWrappers
38 changes: 0 additions & 38 deletions src/main/scala/org/aero/Main.scala

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/scala/org/aero/Schema.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.aero

case class Schema(namespace: String, set: String)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.aero.impl.common
package org.aero.common

import com.aerospike.client.Value

Expand All @@ -8,4 +8,8 @@ trait KeyWrapper[K] {

object KeyWrapper {
def apply[T](f: T => Value): KeyWrapper[T] = (v: T) => f(v)
}
}

trait DefaultKeyWrappers {
implicit val stringKW: KeyWrapper[String] = KeyWrapper(Value.get)
}
31 changes: 31 additions & 0 deletions src/main/scala/org/aero/examples/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.aero.examples

import scala.concurrent.duration._
import org.aero.AeroOps._
import org.aero._

import scala.concurrent.Await
import scala.concurrent.ExecutionContext.Implicits.global

object Main {
def main(args: Array[String]): Unit = {
val host = "localhost"
val port = 3000

implicit val schema = Schema("test", "org-os")
implicit val ac = AeroClient(host, port)

val eventualUnit = for {
_ <- put("002", (WriteBin("key", "002"), WriteBin("string_column", "string"), WriteBin("double_column", 1.1)))
(key, value) <- get("002", ("key".as[String], "double_column".as[Double]))
optionResult <- getOpt("002", "string_column".as[String])
} yield {
println(s"$key = $value") // print 002 = 1.1
println(optionResult) // print Some(String)
}

Await.ready(eventualUnit, Duration.Inf)

ac.close()
}
}
18 changes: 0 additions & 18 deletions src/main/scala/org/aero/impl/reads/DefaultUnmarshallers.scala

This file was deleted.

14 changes: 0 additions & 14 deletions src/main/scala/org/aero/impl/reads/ToNames.scala

This file was deleted.

7 changes: 0 additions & 7 deletions src/main/scala/org/aero/impl/reads/Unmarshaller.scala

This file was deleted.

66 changes: 0 additions & 66 deletions src/main/scala/org/aero/impl/reads/streams/SourceStage.scala

This file was deleted.

29 changes: 0 additions & 29 deletions src/main/scala/org/aero/impl/reads/streams/StreamedReadOps.scala

This file was deleted.

Loading

0 comments on commit fc3b537

Please sign in to comment.