Skip to content

Commit

Permalink
Upgrade to ZIO 2.0.0-RC6 (#500)
Browse files Browse the repository at this point in the history
* upgrade zio version

* fix

* update documentation

* fix compilation error
  • Loading branch information
adamgfraser authored May 3, 2022
1 parent db4a598 commit 0f52a61
Show file tree
Hide file tree
Showing 53 changed files with 958 additions and 900 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ addCommandAlias(
";zioNio/test;examples/test"
)

val zioVersion = "2.0.0-RC5"
val zioVersion = "2.0.0-RC6"

lazy val zioNio = project
.in(file("nio"))
Expand Down
4 changes: 2 additions & 2 deletions docs/essentials/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ they are not in effects. Apart from basic acquire/release actions, the core API
```scala mdoc:silent
val lockOp = (channel: AsynchronousFileChannel) =>
for {
isShared <- channel.lock().acquireReleaseWith(_.release.ignore)(l => IO.succeed(l.isShared))
isShared <- ZIO.acquireReleaseWith(channel.lock())(_.release.ignore)(l => ZIO.succeed(l.isShared))
_ <- printLine(isShared.toString) // false

scoped = ZIO.acquireRelease(channel.lock(position = 0, size = 10, shared = false))(_.release.ignore)
isOverlaping <- ZIO.scoped(scoped.flatMap(l => IO.succeed(l.overlaps(5, 20))))
isOverlaping <- ZIO.scoped(scoped.flatMap(l => ZIO.succeed(l.overlaps(5, 20))))
_ <- printLine(isOverlaping.toString) // true
} yield ()
```
Expand Down
8 changes: 4 additions & 4 deletions examples/src/main/scala/StreamsBasedServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package zio.nio.examples
import zio.nio.InetSocketAddress
import zio.nio.channels.AsynchronousServerSocketChannel
import zio.stream._
import zio.{Clock, Console, ExitCode, RIO, Scope, UIO, ZIO, ZIOAppDefault, ZTraceElement, durationInt}
import zio.{Clock, Console, ExitCode, RIO, Scope, Trace, UIO, ZIO, ZIOAppDefault, durationInt}

object StreamsBasedServer extends ZIOAppDefault {

Expand All @@ -19,7 +19,7 @@ object StreamsBasedServer extends ZIOAppDefault {
.orDie
.exitCode

def server(port: Int)(implicit trace: ZTraceElement): ZIO[Scope, Exception, AsynchronousServerSocketChannel] =
def server(port: Int)(implicit trace: Trace): ZIO[Scope, Exception, AsynchronousServerSocketChannel] =
for {
server <- AsynchronousServerSocketChannel.open
socketAddress <- InetSocketAddress.wildCard(port)
Expand All @@ -28,7 +28,7 @@ object StreamsBasedServer extends ZIOAppDefault {

def handleConnections[R](
server: AsynchronousServerSocketChannel
)(f: String => RIO[R, Unit])(implicit trace: ZTraceElement): ZStream[R, Throwable, Unit] =
)(f: String => RIO[R, Unit])(implicit trace: Trace): ZStream[R, Throwable, Unit] =
ZStream
.scoped(server.accept)
.forever
Expand All @@ -42,7 +42,7 @@ object StreamsBasedServer extends ZIOAppDefault {
.flattenChunks
.take(4)
.via(ZPipeline.utf8Decode)
.run(Sink.foldLeft("")(_ + (_: String)))
.run(ZSink.foldLeft("")(_ + (_: String)))
_ <- channel.close
_ <- Console.printLine("Connection closed")
_ <- f(data)
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/scala/TextFileDump.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object TextFileDump extends ZIOAppDefault {
}

private def dump(charset: Charset, file: Path)(implicit
trace: ZTraceElement
trace: Trace
): ZIO[Any, Exception, Unit] =
ZIO.scoped {
FileChannel.open(file).flatMapNioBlockingOps { fileOps =>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/scala/ToUppercaseAsAService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object ToUppercaseAsAService extends ZIOAppDefault {

private def handleConnection(
socket: SocketChannel
)(implicit trace: ZTraceElement): ZIO[Any, IOException, Long] = {
)(implicit trace: Trace): ZIO[Any, IOException, Long] = {

// this does the processing of the characters received over the channel via a pipeline
// the stream of bytes from the channel is piped, then written back to the same channel's sink
Expand Down
10 changes: 5 additions & 5 deletions nio/src/main/scala-2/zio/nio/channels/package.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package zio.nio

import zio.stacktracer.TracingImplicits.disableAutoTrace
import zio.{ZIO, ZTraceElement}
import zio.{Trace, ZIO}

import java.io.IOException

Expand All @@ -13,12 +13,12 @@ package object channels {

def flatMapNioBlocking[R1, E >: IOException, A](
f: (C, C#BlockingOps) => ZIO[R1, E, A]
)(implicit trace: ZTraceElement): ZIO[R with R1 with Any, E, A] =
)(implicit trace: Trace): ZIO[R with R1 with Any, E, A] =
underlying.flatMap(c => c.flatMapBlocking(f(c, _)))

def flatMapNioBlockingOps[R1, E >: IOException, A](
f: C#BlockingOps => ZIO[R1, E, A]
)(implicit trace: ZTraceElement): ZIO[R with R1 with Any, E, A] = flatMapNioBlocking((_, ops) => f(ops))
)(implicit trace: Trace): ZIO[R with R1 with Any, E, A] = flatMapNioBlocking((_, ops) => f(ops))

}

Expand All @@ -27,12 +27,12 @@ package object channels {
) extends AnyVal {

def flatMapNioNonBlocking[R1, E >: IOException, A](f: (C, C#NonBlockingOps) => ZIO[R1, E, A])(implicit
trace: ZTraceElement
trace: Trace
): ZIO[R with R1, E, A] =
underlying.flatMap(c => c.flatMapNonBlocking(f(c, _)))

def flatMapNioNonBlockingOps[R1, E >: IOException, A](f: C#NonBlockingOps => ZIO[R1, E, A])(implicit
trace: ZTraceElement
trace: Trace
): ZIO[R with R1, E, A] =
flatMapNioNonBlocking((_, ops) => f(ops))

Expand Down
10 changes: 5 additions & 5 deletions nio/src/main/scala-3/zio/nio/channels/package.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package zio.nio

import zio.stacktracer.TracingImplicits.disableAutoTrace
import zio.{ZIO, ZTraceElement}
import zio.{ZIO, Trace}

import java.io.IOException

Expand All @@ -14,11 +14,11 @@ package object channels {

def flatMapNioBlocking[R1, E >: IOException, A](
f: F1[R1, E, A]
)(implicit trace: ZTraceElement): ZIO[R with R1, E, A] = underlying.flatMap(c => c.flatMapBlocking(f(c, _)))
)(implicit trace: Trace): ZIO[R with R1, E, A] = underlying.flatMap(c => c.flatMapBlocking(f(c, _)))

def flatMapNioBlockingOps[R1, E >: IOException, A](
f: BO => ZIO[R1, E, A]
)(implicit trace: ZTraceElement): ZIO[R with R1, E, A] = flatMapNioBlocking((_, ops) => f(ops))
)(implicit trace: Trace): ZIO[R with R1, E, A] = flatMapNioBlocking((_, ops) => f(ops))

}

Expand All @@ -27,12 +27,12 @@ package object channels {
) extends AnyVal {

def flatMapNioNonBlocking[R1, E >: IOException, A](f: (C, BO) => ZIO[R1, E, A])(implicit
trace: ZTraceElement
trace: Trace
): ZIO[R with R1, E, A] =
underlying.flatMap(c => c.flatMapNonBlocking(f(c, _)))

def flatMapNioNonBlockingOps[R1, E >: IOException, A](f: BO => ZIO[R1, E, A])(implicit
trace: ZTraceElement
trace: Trace
): ZIO[R with R1, E, A] =
flatMapNioNonBlocking((_, ops) => f(ops))

Expand Down
Loading

0 comments on commit 0f52a61

Please sign in to comment.