Skip to content
This repository has been archived by the owner on Oct 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #10 from sangria-graphql-org/prepare_release
Browse files Browse the repository at this point in the history
Prepare release to scala 2.13
  • Loading branch information
yanns authored Oct 28, 2019
2 parents 9cbfb3c + b2f8f72 commit 61fb270
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 28 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: scala
scala:
- 2.12.6
- 2.11.11
- 2.12.10
- 2.11.12
- 2.13.0
jdk:
- openjdk8

Expand Down
18 changes: 10 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name := "sangria-akka-streams"
organization := "org.sangria-graphql"
version := "1.0.2-SNAPSHOT"
mimaPreviousArtifacts := Set("org.sangria-graphql" %% "sangria-akka-streams" % "1.0.1")

description := "Sangria akka-streams integration"
homepage := Some(url("http://sangria-graphql.org"))
licenses := Seq("Apache License, ASL Version 2.0" url("http://www.apache.org/licenses/LICENSE-2.0"))

scalaVersion := "2.12.6"
crossScalaVersions := Seq("2.11.11", "2.12.6")
scalaVersion := "2.13.0"
crossScalaVersions := Seq("2.11.12", "2.12.10", scalaVersion.value)

scalacOptions ++= Seq("-deprecation", "-feature")

Expand All @@ -18,9 +18,11 @@ libraryDependencies ++= Seq(

// Publishing

releaseCrossBuild := true
releasePublishArtifactsAction := PgpKeys.publishSigned.value
publishMavenStyle := true
publishArtifact in Test := false
pomIncludeRepository := (_ false)
pomIncludeRepository := (_ => false)
publishTo := Some(
if (version.value.trim.endsWith("SNAPSHOT"))
"snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
Expand All @@ -31,12 +33,12 @@ startYear := Some(2016)
organizationHomepage := Some(url("https://github.com/sangria-graphql"))
developers := Developer("OlegIlyenko", "Oleg Ilyenko", "", url("https://github.com/OlegIlyenko")) :: Nil
scmInfo := Some(ScmInfo(
browseUrl = url("https://github.com/sangria-graphql/sangria-akka-streams.git"),
connection = "scm:git:git@github.com:sangria-graphql/sangria-akka-streams.git"
browseUrl = url("https://github.com/sangria-graphql-org/sangria-akka-streams.git"),
connection = "scm:git:git@github.com:sangria-graphql-org/sangria-akka-streams.git"
))

// nice *magenta* prompt!

shellPrompt in ThisBuild := { state
shellPrompt in ThisBuild := { state =>
scala.Console.MAGENTA + Project.extract(state).currentRef.project + "> " + scala.Console.RESET
}
}
2 changes: 0 additions & 2 deletions project/coverage.sbt

This file was deleted.

10 changes: 10 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resolvers += Resolver.url(
"typesafe sbt-plugins",
url("https://dl.bintray.com/typesafe/sbt-plugins")
)(Resolver.ivyStylePatterns)

addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.12")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.6.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
18 changes: 9 additions & 9 deletions src/main/scala/sangria/streaming/akkaStreams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ object akkaStreams {
class AkkaStreamsSubscriptionStream(implicit materializer: Materializer) extends SubscriptionStream[AkkaSource] {
def supported[T[_]](other: SubscriptionStream[T]) = other.isInstanceOf[AkkaStreamsSubscriptionStream]

def map[A, B](source: AkkaSource[A])(fn: A B) = source.map(fn)
def map[A, B](source: AkkaSource[A])(fn: A => B) = source.map(fn)

def singleFuture[T](value: Future[T]) = Source.fromFuture(value)

def single[T](value: T) = Source.single(value)

def mapFuture[A, B](source: AkkaSource[A])(fn: A Future[B]) =
def mapFuture[A, B](source: AkkaSource[A])(fn: A => Future[B]) =
source.mapAsync(1)(fn)

def first[T](s: AkkaSource[T]) = s.runWith(Sink.head)

def failed[T](e: Throwable) = Source.failed(e).asInstanceOf[AkkaSource[T]]

def onComplete[Ctx, Res](result: AkkaSource[Res])(op: Unit) =
def onComplete[Ctx, Res](result: AkkaSource[Res])(op: => Unit) =
result
.via(OnComplete(() op))
.recover {case e op; throw e}
.via(OnComplete(() => op))
.recover {case e => op; throw e}
.asInstanceOf[AkkaSource[Res]]

def flatMapFuture[Ctx, Res, T](future: Future[T])(resultFn: T AkkaSource[Res]) =
def flatMapFuture[Ctx, Res, T](future: Future[T])(resultFn: T => AkkaSource[Res]) =
Source.fromFuture(future).flatMapMerge(1, resultFn)

def merge[T](streams: Vector[AkkaSource[T]]) = {
Expand All @@ -53,8 +53,8 @@ object akkaStreams {
throw new IllegalStateException("No streams produced!")
}

def recover[T](stream: AkkaSource[T])(fn: Throwable T) =
stream recover {case e fn(e)}
def recover[T](stream: AkkaSource[T])(fn: Throwable => T) =
stream recover {case e => fn(e)}
}

implicit def akkaSubscriptionStream(implicit materializer: Materializer): SubscriptionStream[AkkaSource] = new AkkaStreamsSubscriptionStream
Expand All @@ -65,7 +65,7 @@ object akkaStreams {
val subscriptionStream = new AkkaStreamsSubscriptionStream
}

private final case class OnComplete[T](op: () Unit) extends SimpleLinearGraphStage[T] {
private final case class OnComplete[T](op: () => Unit) extends SimpleLinearGraphStage[T] {
override def toString: String = "OnComplete"

override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
Expand Down
14 changes: 7 additions & 7 deletions src/test/scala/sangria/streaming/AkkStreamsIntegrationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AkkStreamsIntegrationSpec extends WordSpec with Matchers {
}

"mapFuture" in {
res(impl.mapFuture(source(1, 2, 10))(x Future.successful(x + 1))) should be (List(2, 3, 11))
res(impl.mapFuture(source(1, 2, 10))(x => Future.successful(x + 1))) should be (List(2, 3, 11))
}

"first" in {
Expand All @@ -63,7 +63,7 @@ class AkkStreamsIntegrationSpec extends WordSpec with Matchers {
}

"onComplete handles failure" in {
val s = source(1, 2, 3) map { i
val s = source(1, 2, 3) map { i =>
if (i == 2) throw new IllegalStateException("foo")
else i
}
Expand All @@ -79,16 +79,16 @@ class AkkStreamsIntegrationSpec extends WordSpec with Matchers {
}

"flatMapFuture" in {
res(impl.flatMapFuture(Future.successful(1))(i source(i.toString, (i + 1).toString))) should be (List("1", "2"))
res(impl.flatMapFuture(Future.successful(1))(i => source(i.toString, (i + 1).toString))) should be (List("1", "2"))
}

"recover" in {
val obs = source(1, 2, 3, 4) map { i
val obs = source(1, 2, 3, 4) map { i =>
if (i == 3) throw new IllegalStateException("foo")
else i
}

res(impl.recover(obs)(_ 100)) should be (List(1, 2, 100))
res(impl.recover(obs)(_ => 100)) should be (List(1, 2, 100))
}

"merge" in {
Expand Down Expand Up @@ -139,10 +139,10 @@ class AkkStreamsIntegrationSpec extends WordSpec with Matchers {
}

def source[T](elems: T*): Source[T, NotUsed] =
Source.fromIterator(() Iterator(elems: _*))
Source.fromIterator(() => Iterator(elems: _*))

def res[T](s: Source[T, NotUsed]) =
Await.result(s.runFold(List.empty[T]){case (acc, e) acc :+ e}, 2 seconds)
Await.result(s.runFold(List.empty[T]){case (acc, e) => acc :+ e}, 2 seconds)

def res[T](f: Future[T]) =
Await.result(f, 2 seconds)
Expand Down
1 change: 1 addition & 0 deletions version.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version in ThisBuild := "1.0.2-SNAPSHOT"

0 comments on commit 61fb270

Please sign in to comment.