Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 05 2019 14:43
    @typelevel-bot banned @jdegoes
  • Jan 31 2019 21:17
    codecov-io commented #484
  • Jan 31 2019 21:08
    scala-steward opened #484
  • Jan 31 2019 18:19
    andywhite37 commented #189
  • Jan 31 2019 02:41
    kamilongus starred typelevel/cats-effect
  • Jan 30 2019 00:01
    codecov-io commented #483
  • Jan 29 2019 23:51
    deniszjukow opened #483
  • Jan 29 2019 23:37
  • Jan 29 2019 23:22
  • Jan 29 2019 20:26
    Rui-L starred typelevel/cats-effect
  • Jan 29 2019 18:01
    jdegoes commented #480
  • Jan 29 2019 17:04
    thomaav starred typelevel/cats-effect
  • Jan 28 2019 17:43
    asachdeva starred typelevel/cats-effect
  • Jan 28 2019 07:12
    alexandru commented #480
  • Jan 28 2019 05:45
    codecov-io commented #482
  • Jan 28 2019 05:35
    daron666 opened #482
  • Jan 27 2019 13:56
    codecov-io commented #481
  • Jan 27 2019 13:46
    lrodero opened #481
  • Jan 27 2019 05:47
    codecov-io commented #460
  • Jan 27 2019 05:37
    codecov-io commented #460
Daniel Spiewak
@djspiewak
Maybe even merging them together into a cats-effect-platform
Like, there isn’t much point in having a file read or write function without streaming effects, but other things like moving, copying, listing, etc, not to mention more basic stuff like println and exit hooks, not to mention browser things, all could be nicely wrapped
Ryan Peters
@sloshy
I'm trying to build a concurrent variable like structure that resets itself after nobody is using it for some period of time. So multiple subscribers can "acquire" it, and when all have released I set off a timer that, when finished, resets the variable to an initial value provided nobody subscribes during that window. I have the timer part handled with https://christopherdavenport.github.io/agitation/, and I'm thinking semaphore would be good for figuring out when the number of users that have acquired the variable is 0. Semaphore does not have an "unbounded" variant, and I'm wondering whether or not such a thing would even be useful, or if there is a simpler way of expressing what it is I'm going for (that may or may not need semaphore). Maybe Long.MaxValue as the number of permits is a fine way of getting what I need. What are your thoughts?
Fabio Labella
@SystemFw

and I'm thinking semaphore would be good for figuring out when the number of users that have acquired the variable is 0

if you don't need any semantic blocking, just a Ref should be enough

Ryan Peters
@sloshy
I'll try doing it with just Ref then, I think that should work fine. Thanks for the suggestion @SystemFw
Gavin Bisesi
@Daenyth
@sloshy you might also consider chris d's agitation, it has things like resettable timeouts
Ryan Peters
@sloshy
Way ahead of you @Daenyth :D
Gavin Bisesi
@Daenyth
oh wow
yeah you linked to it
haha
excuse me while I go have more coffee :grin:
Ryan Peters
@sloshy
TBF it was a hyperlink, easy to skim right over
And not to the github but to the microsite since it's what I had open at the moment
Fabio Labella
@SystemFw
agitate seems leaky rn (if you cancel agitate your reset is still happening)
also I think there is a race between oldFiber.cancel and buzzer.complete but it's very very likely innocuous
bifunctor
@bifunctor
Hi all
Is there a way to integrate cats effect into akka streams in the sink position?
For example:
    implicit val system = ActorSystem("QuickStart")
    implicit val materializer = ActorMaterializer()
    implicit val executor = system.getDispatcher

    val ticker = Source.tick(0.second, 1.second, "H")
      .runWith(Sink.foreach(println))
the type ticker of the ticker is Future[Done]
Ryan Peters
@sloshy
@bifunctor Are you asking about running IO inside Sink.foreach or are you looking at making the type of ticker be IO[Done]?
bifunctor
@bifunctor
I am looking the run inside the foreach
I think, I have to create Graphstage
Daniel Spiewak
@djspiewak
@bifunctor I think that fs2-reactive-streams is one answer to this. at least it seems like it should be. I don't know much about akka streams.
Ryan Peters
@sloshy
fs2-reactive-streams will get you a stream where multiple libraries form the connecting pieces of it, which might be what you want. Another alternative is to just do an unsafeRunSync inside of the foreach (not my first choice but it should "work"). Personally if it were me I would defer to fs2 as much as possible as it has direct support for cats effect .
I think there's value in not necessarily having to deal with multiple streaming libraries. Mixing and matching them changes semantics and performance expectations. If you get something from Akka Streams in another lib but would prefer to use fs2, that's a good time to use fs2-reactive-streams. If your application is already mostly Akka Streams and you just want to run some isolated pure code in there, just running the IO is also an option (albeit a compromise)
Daniel Spiewak
@djspiewak
a strong point
streaming is really complicated and each library has its own take on it
multiplying those complexities by throwing them together isn't good
Ryan Peters
@sloshy
In one app I worked on I just wrote the akka streams code as "normal Scala" and converted the resulting Future to IO for the rest of the app which was mostly pure. It feels gross, doesn't exactly compose well, but sometimes it's the way you get stuff done.
Paul Snively
@paul-snively
That said: fromPublisher(...runWith(Sink.asPublisher(fanout = false)))
bifunctor
@bifunctor
@sloshy Could you please explain, how did you do that the akka streams code as "normal Scala" and converted ....
Paul Snively
@paul-snively
@bifunctor: When you run an Akka stream, you get a Future[T]. You can put that expression in IO.fromFuture.
tl;dr Don't run the Akka stream, since Futures start immediately. Put the run expression in IO.fromFuture.
@sloshy : Kinda too bad AWS SDK 2.x uses reactive-streams, but that does present a reasonable use-case for fs2-reactive-streams.
bifunctor
@bifunctor

@paul-snively How could you convert this

    implicit val system = ActorSystem("QuickStart")
    implicit val materializer = ActorMaterializer()
    implicit val executor = system.getDispatcher

    val ticker = Source.tick(0.second, 1.second, 1)
      .runWith(Sink.fromGraph(new StdoutSink))

to IO\?

Paul Snively
@paul-snively
What is ticker's type?
bifunctor
@bifunctor
Sorry
    implicit val system = ActorSystem("QuickStart")
    implicit val materializer = ActorMaterializer()
    implicit val executor = system.getDispatcher

    Source.tick(0.second, 1.second, 1)
      .runWith(Sink.foreach(println))
Paul Snively
@paul-snively
OK. What is that expression's type?
bifunctor
@bifunctor
Int
Paul Snively
@paul-snively
Is it?
Ryan Peters
@sloshy
Should be Future[Done] as mentioned above I think
Paul Snively
@paul-snively
So wrap it in IO.fromFuture.
bifunctor
@bifunctor
Yes, but then I have to run unsafeRunSync
@paul-snively But I would never receive the number 1
try it out
Paul Snively
@paul-snively
Well, you shouldn't. Let's ask this: why do you want to convert the Future to IO?
Better yet: what behavior do you want?
bifunctor
@bifunctor
I would like to use http4s client
that because I have to use IO
Paul Snively
@paul-snively
OK. So you almost certainly want to use IOApp, too.