Questions tagged [fs2]

FS2: Functional Streams for Scala

FS2: Functional Streams for Scala - is a streaming I/O library. The design goals are compositionality, expressiveness, resource safety, and speed.

149 questions
0
votes
3 answers

Interleave multiple streams

I have a list of streams List[Stream[_]], size of list is known at the beginning of function, size of each stream equals n or n+1. I'd like to obtain interleave stream e.g. def myMagicFold[A](s: List[Stream[A]]): Stream[A] val streams =…
jker
  • 465
  • 3
  • 13
0
votes
0 answers

Reading using doobie

I have defined repository: trait Repo[F[_]] { def findAll: Stream[F, Stop] } and it's implementation: class DoobieRepo[F[_]: Sync](xa: Transactor[F]) extends Repo[F] { override def findAll: Stream[F, Stop] = …
oybek
  • 630
  • 4
  • 14
0
votes
1 answer

Intellij: Expression of type IO[Long] doesn't conform to expected type FS2_[O2_]

I tried the code of this Blog: a-streaming-library-with-a-superpower-fs2-and-functional-programming In Intellij this code: Stream("bob", "alice", "joe") .evalMap(name => IO.fromFuture(IO(loadUserIdByName(name)))) // <- here is the exception …
pme
  • 14,156
  • 3
  • 52
  • 95
0
votes
1 answer

fs2.Stream observeAsync does not execute a given sink asynchronously

I'm experimenting with fs2.Stream concurrent features and got some misunderstanding about how it works. I would like to send stream content through some sink in parallel. Here is what I tried: object TestParallelStream extends App { val…
Some Name
  • 8,555
  • 5
  • 27
  • 77
0
votes
0 answers

How to run FS2 streams when no Sync instance available?

If I end up with an e.g. Stream[Id, A], I can translate the effect Pure with the trivial Id ~> Pure. However, if I've ended up with a stream of a different strict effect type, e.g. Stream[Option, A], how can I convert this to a Option[Vector[A]] (or…
Hugh
  • 8,872
  • 2
  • 37
  • 42
0
votes
1 answer

Idiomatic way to handle multiple concurrent streams in Scala

I have a list of streams that, upon calling their next() will sleep random amount of time and then read one char from a different source. I am trying to write a consumer(s) that will keep calling these streams until EOF and build a common dictionary…
smohamed
  • 3,234
  • 4
  • 32
  • 57
0
votes
1 answer

Ideal chunk in scala fs2 stream performance gain in production

was wondering if the increase in chunk size in scala fs2 stream will give the performance gain? import cats.effect.{IO, Sync} import fs2.{io, text} import java.nio.file.Paths def fahrenheitToCelsius(f: Double): Double = (f - 32.0) *…
vkt
  • 1,401
  • 2
  • 20
  • 46
0
votes
1 answer

Runtime Configuration of Cassandra connection in Phantom DSL

I'm using phantom to connect to Apache Cassandra and want to configure the connector at runtime, i.e. I want to parse some configuration file, extract a list of Cassandra databases and pass that somehow to my Database object. I followed this guide…
Thomas Bach
  • 103
  • 7
0
votes
1 answer

Type mismatch when following example from documentation in fs2

I am trying to build an application using FS2 (0.10.0). I've taken this example from the documentation: import fs2._ // import fs2._ import fs2.async // import fs2.async import scala.concurrent.ExecutionContext // import…
Pere Villega
  • 16,429
  • 5
  • 63
  • 100
0
votes
1 answer

FS2 Running streams in sequence

I have a fairly simple use case. I have two web service calls one fetches products and another fetches relationship. I want to run fetchProducts() first extract a field from the set of products and then pass the output to fetchRelationships(ids:…
0
votes
1 answer

Scala : File reading to Build an external Merge Sort

I want to implement an external Merge Sort in Scala. It is used to sort huge files which can not fit in the main memory in their entirety. Details can be found here :- How external merge sort algorithm works? Now, I need to read chunks of the file,…
Aarsh Shah
  • 91
  • 7
0
votes
1 answer

Scala fs2 Streams with Chunks and Tasks?

// Simulated external API that synchronously returns elements one at a time indefinitely. def externalApiGet[A](): A = ??? // This wraps with the proper fs2 stream that will indefinitely return values. def wrapGetWithFS2[A](): Stream[Task,…
clay
  • 18,138
  • 28
  • 107
  • 192
0
votes
1 answer

Concurrently running Scala FS2 Streams

I am trying to model a system which is a load generator for a website. The website has pages which, for now, are Strings. type Page = String val pages: Vector[Page] = Stream.eval(Task.delay { new…
Binil Thomas
  • 13,699
  • 10
  • 57
  • 70
1 2 3
9
10