Skip to content
This repository has been archived by the owner on Nov 22, 2017. It is now read-only.

Commit

Permalink
Upgrade to akka stream 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fehmicansaglam committed Jul 15, 2015
1 parent 716e517 commit 0dca8b6
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
lazy val commonSettings = Seq(
organization := "net.fehmicansaglam",
version := "0.6-SNAPSHOT",
scalaVersion := "2.11.6",
scalaVersion := "2.11.7",
scalacOptions := Seq(
"-deprecation",
"-encoding", "UTF-8", // yes, this is 2 args
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.fehmicansaglam.tepkin.examples

import akka.stream.ActorFlowMaterializer
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Source
import akka.util.Timeout
import net.fehmicansaglam.bson.BsonDocument
Expand Down Expand Up @@ -31,7 +31,7 @@ object Example1 extends App {
val collection2 = db("collection2")

implicit val timeout: Timeout = 30.seconds
implicit val mat = ActorFlowMaterializer()
implicit val mat = ActorMaterializer()

// Batch document source
def documents(n: Int): Source[List[BsonDocument], Unit] = Source {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.fehmicansaglam.tepkin.examples

import akka.stream.ActorFlowMaterializer
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Source
import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.{BsonDocument, Bulk}
Expand All @@ -23,7 +23,7 @@ object SinkExample extends App {
// Obtain reference to the collection "collection2" using database
val collection2 = db("collection2")

implicit val mat = ActorFlowMaterializer()
implicit val mat = ActorMaterializer()

// Batch document source
def documents(n: Int): Source[List[BsonDocument], Unit] = Source {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.fehmicansaglam.tepkin.examples

import akka.stream.ActorFlowMaterializer
import akka.stream.ActorMaterializer
import akka.util.Timeout
import net.fehmicansaglam.bson.BsonDocument
import net.fehmicansaglam.tepkin.MongoClient
Expand All @@ -14,7 +14,7 @@ object TailableCursorExample extends App {
import client.{context, ec}

implicit val timeout: Timeout = 5.seconds
implicit val mat = ActorFlowMaterializer()
implicit val mat = ActorMaterializer()

val db = client("tepkin")
val messages = db("messages")
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object Dependencies {
val akkaV = "2.3.11"
val akkaStreamV = "1.0-RC3"
val akkaStreamV = "1.0"
val scalatestV = "2.2.4"
}
4 changes: 2 additions & 2 deletions tepkin/src/main/scala/net/fehmicansaglam/tepkin/GridFs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.io._
import java.security.MessageDigest

import akka.actor.ActorRef
import akka.stream.FlowMaterializer
import akka.stream.Materializer
import akka.stream.io.SynchronousFileSource
import akka.stream.scaladsl.Source
import akka.util.{ByteString, Timeout}
Expand Down Expand Up @@ -33,7 +33,7 @@ class GridFs(db: MongoDatabase, prefix: String = "fs") {
/**
* Puts the given file into GridFS.
*/
def put(file: File)(implicit mat: FlowMaterializer, ec: ExecutionContext, timeout: Timeout): Future[BsonDocument] = {
def put(file: File)(implicit mat: Materializer, ec: ExecutionContext, timeout: Timeout): Future[BsonDocument] = {
val fileId = BsonObjectId.generate
val zero = (0, MessageDigest.getInstance("MD5"))

Expand Down
11 changes: 5 additions & 6 deletions tepkin/src/test/scala/net/fehmicansaglam/tepkin/GridFsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package net.fehmicansaglam.tepkin
import java.io.{File, FileInputStream}
import java.security.MessageDigest

import akka.stream.ActorFlowMaterializer
import akka.stream.ActorMaterializer
import akka.util.Timeout
import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
Expand All @@ -28,8 +28,7 @@ class GridFsSpec
val db = client("tepkin")
val fs = db.gridFs()

import client.ec
import client.context
import client.{context, ec}

implicit val timeout: Timeout = 30.seconds

Expand All @@ -47,7 +46,7 @@ class GridFsSpec
override protected def afterAll() = client.shutdown()

"A GridFs" should "put and find and delete File" in {
implicit val mat = ActorFlowMaterializer()
implicit val mat = ActorMaterializer()

val result = for {
put <- fs.put(new File(getClass.getResource("/sample.pdf").getPath))
Expand All @@ -63,7 +62,7 @@ class GridFsSpec
}

it should "put and get and delete File" in {
implicit val mat = ActorFlowMaterializer()
implicit val mat = ActorMaterializer()

val result = for {
put <- fs.put(new File(getClass.getResource("/sample.pdf").getPath))
Expand All @@ -84,7 +83,7 @@ class GridFsSpec
}

it should "put and get and delete FileInputStream" in {
implicit val mat = ActorFlowMaterializer()
implicit val mat = ActorMaterializer()

val result = for {
put <- fs.put("sample.pdf", new FileInputStream(getClass.getResource("/sample.pdf").getPath))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.fehmicansaglam.tepkin

import akka.stream.ActorFlowMaterializer
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Source
import akka.util.Timeout
import net.fehmicansaglam.bson.BsonDocument
Expand Down Expand Up @@ -61,7 +61,7 @@ class MongoCollectionSpec
}

it should "insert and find 10 documents" in {
implicit val mat = ActorFlowMaterializer()
implicit val mat = ActorMaterializer()

val documents = (1 to 10).map(i => $document("name" := s"fehmi$i"))

Expand All @@ -78,7 +78,7 @@ class MongoCollectionSpec
}

it should "insert and find 1000 documents" in {
implicit val mat = ActorFlowMaterializer()
implicit val mat = ActorMaterializer()

val documents = (1 to 1000).map(i => $document("name" := s"fehmi$i"))

Expand All @@ -95,7 +95,7 @@ class MongoCollectionSpec
}

it should "insert and find 100000 documents" in {
implicit val mat = ActorFlowMaterializer()
implicit val mat = ActorMaterializer()

val documents: Source[List[BsonDocument], Unit] = Source {
Iterable.tabulate(100) { _ =>
Expand Down Expand Up @@ -165,7 +165,7 @@ class MongoCollectionSpec
}

it should "group by and calculate a sum" in {
implicit val mat = ActorFlowMaterializer()
implicit val mat = ActorMaterializer()

val documents: Seq[BsonDocument] = Seq(
("_id" := 1) ~ ("cust_id" := "abc1") ~ ("status" := "A") ~ ("amount" := 50),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.fehmicansaglam.tepkin

import akka.stream.ActorFlowMaterializer
import akka.stream.ActorMaterializer
import akka.util.Timeout
import net.fehmicansaglam.bson.BsonDocument
import org.scalatest._
Expand All @@ -21,15 +21,14 @@ class MongoDatabaseSpec
val client = MongoClient("mongodb://localhost")
val db = client("tepkin")

import client.ec
import client.context
import client.{context, ec}

implicit val timeout: Timeout = 30.seconds

override protected def afterAll() = client.shutdown()

"A MongoDatabase" should "list collections" in {
implicit val mat = ActorFlowMaterializer()
implicit val mat = ActorMaterializer()

val result = for {
source <- db.listCollections()
Expand Down

0 comments on commit 0dca8b6

Please sign in to comment.