Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve API consistency and docs. #228

Merged
merged 5 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/essentials/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ Reading and writing is performed as effects where raw `Byte` content is wrapped
```scala mdoc:silent
val readWriteOp = (channel: AsynchronousFileChannel) =>
for {
chunk <- channel.read(20, 0)
chunk <- channel.readChunk(20, 0L)
text = chunk.map(_.toChar).mkString
_ <- putStrLn(text)

input = Chunk.fromArray("message".toArray.map(_.toByte))
_ <- channel.write(input, 0)
_ <- channel.writeChunk(input, 0L)
} yield ()
```

Expand Down
4 changes: 2 additions & 2 deletions docs/essentials/sockets.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ val server = AsynchronousServerSocketChannel()
def doWork(channel: AsynchronousSocketChannel): ZIO[Console with Clock, Throwable, Unit] = {
val process =
for {
chunk <- channel.read(3)
chunk <- channel.readChunk(3)
str = chunk.toArray.map(_.toChar).mkString
_ <- putStrLn(s"received: [$str] [${chunk.length}]")
} yield ()
Expand All @@ -59,7 +59,7 @@ Reading and writing to socket:
```scala mdoc:silent
for {
serverFiber <- server.fork
clientFiber <- clientM.use(_.write(Chunk.fromArray(Array(1, 2, 3).map(_.toByte)))).fork
clientFiber <- clientM.use(_.writeChunk(Chunk.fromArray(Array(1, 2, 3).map(_.toByte)))).fork
_ <- clientFiber.join
_ <- serverFiber.join
} yield ()
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/scala/StreamsBasedServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object StreamsBasedServer extends App {
_ <- console.putStrLn("Received connection")
data <- ZStream
.fromEffectOption(
channel.read(64).tap(_ => console.putStrLn("Read chunk")).orElse(ZIO.fail(None))
channel.readChunk(64).tap(_ => console.putStrLn("Read chunk")).orElse(ZIO.fail(None))
)
.flattenChunks
.take(4)
Expand Down
Loading