Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jsilva
Copy link
Contributor

@jsilva jsilva commented Sep 22, 2019

Pull request for #1460

Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up @jsilva! This has to stay a stream emitting chunks, otherwise performance will plummet.

Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jsilva. Could you revert the unrelated formatting changes?

} else {
a.toByte
}
val buf = Array.ofDim[Byte](chunkSize)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The buf has to be re-created every time pull runs, or we'll be mutating chunks that have already been emitted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this

}
val buf = Array.ofDim[Byte](chunkSize)
def pull(): Chunk[Byte] = {
val bytesRead = is.read(buf)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be wrapped in try/catch and should catch IOException and re-throw it using StreamEffect.fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, thanks for help


final def fromInputStream(is: InputStream): StreamEffect[Any, Nothing, Byte] =
StreamEffect[Any, Nothing, Byte] {
Managed.effectTotal {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a total effect, I can see Managed.makeEffect which is probably more appropriate here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the Managed only returns a thunk that, so in that regard it should be total

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how we treated all StreamEffect code so far.

Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. This is great.

The only thing we lost during this porting is the use of the Blocking executor, which I will take care of in #1483.

@iravid iravid merged commit 166c27d into zio:master Sep 22, 2019
XLPI pushed a commit to XLPI/zio that referenced this pull request Sep 22, 2019
* Port ZStream.fromInputStream (the one in platform.scala) to StreamEffect zio#1460

* Port ZStream.fromInputStream (the one in platform.scala) to StreamEffect zio#1460

* code review updates

* code review updates

* moved buffer to pull call, to avoid mutation

* catch exception and use StreamEffectChunk
ghostdogpr pushed a commit that referenced this pull request Sep 22, 2019
* Migrate StackBoolSpec to ZIO Tests (#1647)

* Fix build issues introduced by bundling (#1754)

* #1647 - converted SerializableSpec to ZTest (#1769)

* Move PlatformLive.ExecutorUtil to Executor companion object. private zio.internal.Sync (#1770)

* Modified dies signature (#1768)

* Modified dies signature

* Added type parameter

* Removed type parameter

* Restart schedule on end in ZStream#scheduleWith (#1767)

* Restart schedule on end

* Remove unused state, add docs

* Port ZStream.fromInputStream to StreamEffect #1460 (#1772)

* Port ZStream.fromInputStream (the one in platform.scala) to StreamEffect #1460

* Port ZStream.fromInputStream (the one in platform.scala) to StreamEffect #1460

* code review updates

* code review updates

* moved buffer to pull call, to avoid mutation

* catch exception and use StreamEffectChunk

* Specify that this fiber will be "inner interrupted" on joining an interrupted Fiber (#1774)

* #1647: Migrate all tests to ZIO Test: Platform spec (#1775)

* Migrate Fiber tests to ZIO Tests (#1647) (#1777)

* Update zio-interop-java to 1.1.0.0-RC5 (#1781)

* Update fs2-core to 2.0.1 (#1779)

* Update sbt-pgp to 1.1.2 (#1780)

* Update zio-interop-monix to 3.0.0.0-RC6 (#1782)

* updated resources page to add my examples (#1783)

* Migrate ZScheduleSpec to ZIO Tests (#1647)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants