Skip to content

Commit 90cdad3

Browse files
committed
added mima plugin, updated depemdencies
1 parent 4c87d52 commit 90cdad3

File tree

6 files changed

+35
-11
lines changed

6 files changed

+35
-11
lines changed

build.sbt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
val dottyVersion = "3.0.1"
33
//val dottyVersion = dottyLatestNightlyBuild.get
44

5-
ThisBuild/version := "2.0.7-SNAPSHOT"
5+
ThisBuild/version := "2.1.0"
66
ThisBuild/versionScheme := Some("semver-spec")
77

88
val sharedSettings = Seq(
99
organization := "com.github.rssh",
1010
scalaVersion := dottyVersion,
1111
name := "scala-gopher",
1212
resolvers += "Local Ivy Repository" at "file://"+Path.userHome.absolutePath+"/.ivy2/local",
13-
libraryDependencies += "com.github.rssh" %%% "dotty-cps-async" % "0.9.3-SNAPSHOT",
13+
libraryDependencies += "com.github.rssh" %%% "dotty-cps-async" % "0.9.3",
1414
libraryDependencies += "org.scalameta" %%% "munit" % "0.7.27" % Test,
1515
)
1616

@@ -42,6 +42,7 @@ lazy val gopher = crossProject(JSPlatform, JVMPlatform)
4242
s"-javaagent:${System.getProperty("user.home")}/.ivy2/local/com.github.rssh/trackedfuture_3/0.5.0/jars/trackedfuture_3-assembly.jar"
4343
)
4444
*/
45+
mimaPreviousArtifacts := Set( "com.github.rssh" %% "scala-gopher" % "2.0.6")
4546
).jsSettings(
4647
libraryDependencies += ("org.scala-js" %%% "scalajs-java-logging" % "1.0.0").cross(CrossVersion.for3Use2_13),
4748
// TODO: switch to ModuleES ?

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1")
33
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
44
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
55
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0")
6-
6+
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.0")

shared/src/main/scala/gopher/Channel.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ object Channel:
4747
case class FRead[F[_],A](a:A, ch: F[A])
4848
case class Write[F[_],A](a: A, ch: WriteChannel[F,A])
4949

50+
import cps.stream._
51+
52+
5053

5154
end Channel
5255

shared/src/main/scala/gopher/ReadChannel.scala

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ import scala.concurrent.duration.Duration
1212
import java.util.logging.{Level => LogLevel}
1313

1414
/**
15-
* ReadChannel: Interface providing reading API.
15+
* ReadChannel: Interface providing asynchronous reading API.
1616
*
1717
**/
1818
trait ReadChannel[F[_], A]:
1919

2020
thisReadChannel =>
2121

22+
/**
23+
* Special type which is used in select statement.
24+
*@see [gopher.Select]
25+
**/
2226
type read = A
2327

2428
def gopherApi: Gopher[F]
@@ -45,7 +49,8 @@ trait ReadChannel[F[_], A]:
4549

4650
/**
4751
* blocked read: if currently not element available - wait for one.
48-
* Can be used only inside async block
52+
* Can be used only inside async block.
53+
* If stream is closed and no values to read left in the stream - throws StreamClosedException
4954
**/
5055
transparent inline def read(): A = await(aread())(using rAsyncMonad)
5156

@@ -74,9 +79,18 @@ trait ReadChannel[F[_], A]:
7479
b.result()
7580
}
7681

82+
/**
83+
* take first `n` elements.
84+
* should be called inside async block.
85+
**/
7786
transparent inline def take(n: Int): IndexedSeq[A] =
7887
await(atake(n))(using rAsyncMonad)
7988

89+
/**
90+
* read value and return future with
91+
* - Some(value) if value is available to read
92+
* - None if stream is closed.
93+
**/
8094
def aOptRead(): F[Option[A]] =
8195
asyncMonad.adoptCallbackStyle( f =>
8296
addReader(SimpleReader{ x => x match
@@ -86,6 +100,13 @@ trait ReadChannel[F[_], A]:
86100
})
87101
)
88102

103+
/**
104+
* read value and return
105+
* - Some(value) if value is available to read
106+
* - None if stream is closed.
107+
*
108+
* should be called inside async block.
109+
**/
89110
transparent inline def optRead(): Option[A] = await(aOptRead())(using rAsyncMonad)
90111

91112
def foreach_async(f: A=>F[Unit]): F[Unit] =
@@ -112,6 +133,7 @@ trait ReadChannel[F[_], A]:
112133
transparent inline def foreach(inline f: A=>Unit): Unit =
113134
await(aforeach(f))(using rAsyncMonad)
114135

136+
115137
def map[B](f: A=>B): ReadChannel[F,B] =
116138
new MappedReadChannel(this, f)
117139

shared/src/main/scala/gopher/WriteChannel.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import scala.annotation.targetName
77
import scala.concurrent.duration.FiniteDuration
88
import scala.util.Try
99

10+
1011
trait WriteChannel[F[_], A]:
1112

1213
type write = A

shared/src/test/scala/gopher/stream/BasicGeneratorSuite.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,9 @@ class BasicGeneratorSuite extends FunSuite {
6666
} }
6767
}
6868

69-
70-
71-
69+
7270
}
7371

74-
75-
/*
7672
test("exception should break loop in gopher generator") {
7773
val channel = asyncStream[ReadChannel[Future, Int]] { out =>
7874
for(i <- 1 to N) {
@@ -89,7 +85,8 @@ class BasicGeneratorSuite extends FunSuite {
8985

9086
res.failed.map(ex => assert(ex.getMessage()=="bye"))
9187

92-
}*/
88+
}
89+
9390

9491

9592
}

0 commit comments

Comments
 (0)