Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 18 04:04
    scala-steward review_requested #1595
  • Sep 18 04:04
    scala-steward review_requested #1595
  • Sep 18 04:04
    scala-steward opened #1595
  • Sep 17 20:38
    neko-kai closed #1593
  • Sep 17 20:27
    neko-kai closed #1594
  • Sep 17 20:19
    neko-kai auto_merge_enabled #1593
  • Sep 17 20:18
    neko-kai synchronize #1593
  • Sep 17 20:16
    neko-kai auto_merge_disabled #1593
  • Sep 17 20:16
    neko-kai auto_merge_enabled #1593
  • Sep 17 20:15
    neko-kai auto_merge_enabled #1594
  • Sep 17 20:08
    scala-steward review_requested #1594
  • Sep 17 20:08
    scala-steward review_requested #1594
  • Sep 17 20:08
    scala-steward opened #1594
  • Sep 17 20:08
    scala-steward review_requested #1593
  • Sep 17 20:08
    scala-steward review_requested #1593
  • Sep 17 20:08
    scala-steward opened #1593
  • Sep 16 16:08
    neko-kai closed #1590
  • Sep 16 16:06
    neko-kai auto_merge_enabled #1592
  • Sep 16 16:05
    scala-steward review_requested #1592
  • Sep 16 16:05
    scala-steward review_requested #1592
Kai
@neko-kai
:+1:
@DamianReeves I'm not sure what you mean exactly, but it works for me to add Has-like methods like this https://scastie.scala-lang.org/Xg6LV87fT5aMEUdELvQGAw
Damian Reeves
@DamianReeves
@Kai thanks. After playing around a bit yesterday I did happen to stumble on a similar solution.
Didac
@umbreak

@neko-kai It does work what you suggested, but I get the following error:

app   Caused by: izumi.distage.model.exceptions.MissingRefException: Proxy for {type.scala.collection.immutable.Set[=A]} is not yet initialized

This is due to the fact that I have something like:

make[C].from((aSet: Set[A]) => new C(aSet.toList))

Since class C requires a List[A]. It seems that in the moment when that line is executed, the set is not yet fully initialzed. If I change C to require a Set[A] it works, but it is not what I want

Didac
@umbreak
Is there a way to work around this? or I have to do something like:
class C[A](set: Set[A]){
   private lazy val list = set.toList
}
Kai
@neko-kai
@umbreak Is C itself included into Set[A] - perhaps transitively? That's the only thing that would cause a proxy to be generated to allow a cyclic dependency to still work. You may try to print or inspect your wiring data to locate the cycle (https://izumi.7mind.io/distage/debugging#pretty-printing-plans, https://izumi.7mind.io/distage/debugging#graphviz-rendering ) but if it's deliberate than you'd pretty much have to use a lazy constructor
Didac
@umbreak
Well, the setup is more complicated than A, B and C…so it could be that is inluded transitively yes. I’ll check that using the debugging tools. Thanks again :)
Kai
@neko-kai
@umbreak You can also disable support for cycles by using Injector.NoCycles() instead of Injector(), that would cause it to fail earlier and maybe locate the issue easier
Edvin Lundberg
@Edvin-san

Hi, just wanted to say that the new distage 1.0.4 version seems to have fixed my shutdown issues :thumbsup:

Hi! I think I may have a problem with resources not being cleaned up. When my app receives SIGTERM it starts shutting down (I can see AppShutdownStrategy "Going to shut down..." in logs).
I can also see http4s PoolManager "Shutting down connection pool". But then it just sits there. Do you have any recommendation on how to debug this in distage? Can I see which resource is causing the problem?

Kai
@neko-kai
That's great, so it wasn't an issue in your code, but in our :D
jatcwang
@jatcwang:matrix.org
[m]
Hi, I'm having a blast playing around with Tag/LightTypeTag so thanks :) Question: Is it possible to summon LightTypeTag[T] directly? (I don't use anything else from Tag)
jatcwang
@jatcwang:matrix.org
[m]
hm just realized LightTypeTag doesn't have a type param. Guess it won't work then
Kai
@neko-kai
@jatcwang:matrix.org Actually you can summon using LTag[T]
jatcwang
@jatcwang:matrix.org
[m]
Oh lovely thanks!
It's still a wrapper around LightTypeTag so I still need to call tag.tag quite a bit. Still good to have since it's less work for the compiler. Not a big issue
Kai
@neko-kai
@jatcwang:matrix.org The difference between LTag and Tag (aside from the Class[_] field) is that Tag will assemble a Tag from evidence for type parameters, e.g def x[F[_]: TagK, A: Tag]: Tag[F[A]] = Tag[F[A]]
But LTag will break on that. You can also summon "weak" versions using WeakTag[A]/LTag.Weak[A] - these will not attempt to resolve type parameters using tag evidence but will just include unresolved type parameters as written, e.g. def x[A] = WeakTag[A]; x[Int] = literal WeakTag[A], not WeakTag[Int]
jatcwang
@jatcwang:matrix.org
[m]
I'll play around with it and see whether LTag is good enough for me. Thanks for the info :)
Edvin Lundberg
@Edvin-san
Hi, I think there is a bug when using named instances in the testkit. Tried to create one in moduleOverrides but got a wiring error that about missing instance "required by ∅". I may be able to provide an example later but wanted to flag early.
Kai
@neko-kai
@Edvin-san A reproduction would be great! There are tests for named instances in tests, but this error doesn't seem to be caught in our existing test suites (is that test similar? https://github.com/7mind/izumi/blob/develop/distage/distage-testkit-scalatest/src/test/scala/izumi/distage/testkit/distagesuite/DistageTestExample.scala#L156)
Stan Sobolev
@Jacke

Hey guys, I use conversion from this library
import izumi.functional.bio.catz._

How can I resolve issues like this

Symbol 'type cats.effect.Bracket' is missing from the classpath.
[error] This symbol is required by 'method izumi.functional.bio.CatsConversions5.BIOToBracket'.
[error] Make sure that type Bracket is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
[error] A full rebuild may help if 'CatsConversions5.class' was compiled against an incompatible version of cats.effect.
[error]       transactor.trans

Is it possible to use izumi.functional.bio.catz for Cats effect v3?

Kai
@neko-kai

Is it possible to use izumi.functional.bio.catz for Cats effect v3?

@Jacke No, not yet

Next release will have CE3 support, probably within 1-2 weeks
Stan Sobolev
@Jacke
Got it, thanks very much.
Edvin Lundberg
@Edvin-san
@neko-kai My bad, I tried to produce a small example but instead found out the issue. Basically I forgot to use the Id tag in the test dependency. Like in the test you linked set: Set[SetElement] @Id("unmemoized-set") I forgot about the @Id("unmemoized-set") so my test was actually dependent on the unnamed instance which was missing from dependency graph. I was confused about the error message since it wasn't clear that the unnamed instance was needed for the test, perhaps an improvement for future releases?
Kai
@neko-kai
@Edvin-san I've added an issue to track this: 7mind/izumi#1465 - I think what may help in situations like this is for the error message to list all bindings with the same type - - so you may see at a glance that there's another named element and you've requested an unnamed element.
Edvin Lundberg
@Edvin-san
@neko-kai Nice, that would definitely be helpful!
Edvin Lundberg
@Edvin-san

Hi, I recently introduced a circular dependency to my project. I get a ProvisioningException when running my application, but not when running my wiring test.
The error is something like:

izumi.distage.model.exceptions.ProvisioningException: Provisioner failed on 1 of 153 required operations, just 114 succeeded:
- {type.com.myproject.A} (MyPlugin.scala:179), NoopProvisionerImplCalled: izumi.distage.model.exceptions.NoopProvisionerImplCalled: ProxyProviderFailingImpl can't create cycle-breaking proxies, failed op: {type.com.myproject.A} (MyPlugin.scala:179) := proxy.cogen({type.com.myproject.B}: deferred) {
    {type.com.myproject.A}

I tried adding distage-core-proxy-cglib but I still get the same error. Any thoughts?
Btw, distage version 1.0.5

Kai
@neko-kai
@Edvin-san Do you use Injector.NoCycles/.NoProxies to construct Injector or do you set activation Cycles -> Cycles.Disable or Cycles.Byname? or if you use Typesafe config with distage-framework role launcher, is there a config option activation.cycles = disabled/byname ?
There are a few ways to disable proxy support, but they all have to be explicit. By default it's enabled (except on Scala.js) and has to be manually disabled
Harish
@hsubra89
Hey, Is there any update on support for CE3?
Edvin Lundberg
@Edvin-san

@neko-kai No, I couldn't find that I use any of what you suggested. Does the error message suggest that it has been disabled?
This is my WiringTest + some context

object WiringTest
    extends PlanCheck.Main(
      MainProd,
      cfg = PlanCheckConfig(checkConfig = false), // Could this be the cause? I can't easily enable it.
    )

object MainProd extends MainBase(Activation(Repo -> Repo.Prod))

abstract class MainBase(activation: Activation) extends RoleAppMain.LauncherBIO2[IO] {
  override def requiredRoles(argv: RoleAppMain.ArgV): Vector[RawRoleParams] = Vector(RawRoleParams(MyRole.id))

  override def pluginConfig: PluginConfig = PluginConfig.cached(packagesEnabled = Seq("com.myproject.plugins")) // Contains all plugin defs

  override protected def roleAppBootOverrides(argv: RoleAppMain.ArgV): Module =
    super.roleAppBootOverrides(argv) ++ new ModuleDef {
      make[Activation].named("default").fromValue(activation)
    }
}

// Also have a RunLocal in test project to run application using containers
object RunLocal extends MainBase(Activation(Repo -> Repo.Prod)) {
  override def pluginConfig: PluginConfig =
    super.pluginConfig
      .overriddenBy(ContainerPlugin)
}

I could get the ProvisioningException when running RunLocal but not when running WiringTest.
Also, I could see when running RunLocal that it prints (some while before error message)

W 2021-06-14T13:22:35.132 (PlanCircularDependencyCheck.scala:21)  …arDependencyCheck.verify.18 [1:main] phase=late Circular dependency has been resolved with proxy for key={type.com.myproject.A}
Edvin Lundberg
@Edvin-san
Btw, I worked around it by getting rid of the cyclic dependency so there is no urgent issue :)
Kai
@neko-kai
@Edvin-san Yes the error suggests that proxy support was disabled since ProxyProviderFailingImpl only appears if Cycles activation is set to Disable or Byname... By default CglibProxyProvider is used
Aleksandar Skrbic
@aleksandarskrbic
Hi, I just started playing with Izumi and realized that BIO is deprecated to IO2, etc, so I was wondering is it ok to use old type aliases since they aesthetically better for me personally?
Kai
@neko-kai
@aleksandarskrbic I would recommend against that since old aliases will be removed in 1.1.0 (they were deprecated in 1.0)
Aleksandar Skrbic
@aleksandarskrbic
@neko-kai thanks!
I have one more question regarding to using BIO in TF style with ZIO, is it possible to use zio.Schedule?
import izumi.functional.bio.{F, IO2}
import zio.{Runtime, Schedule, ZIO}
import zio.duration._

object Main extends scala.App {

  val rt = Runtime.default

  val repeatEffect = ZIO.effect(println("Effect")).repeat(Schedule.spaced(1.second))
  //rt.unsafeRun(repeatEffect)

  def repeatEffectTF[F[+_, +_]: IO2] =
    F.sync(println("Effect TF"))

  rt.unsafeRun(repeatEffectTF[zio.IO])
}
Is it possible to define schedule for repeatEffectTF
Vladyslav
@VladPodilnyk
@aleksandarskrbic you probably want to do smth like this, since Izumi's IO2 doesn't provide any repeat capabilities
trait Scheduler2[F[_, _]] {
  def repeat[E, A, B](eff: F[E, A])(scheduler: Schedule[Clock, A, B]): F[E, B]
}

object Scheduler2 {
  def apply[F[+_, +_]: Scheduler2]: Scheduler2[F] = implicitly

  implicit def fromZIO(implicit zClock: Clock): Scheduler2[IO] = new Scheduler2[IO] {
    override def repeat[E, A, B](eff: IO[E, A])(scheduler: Schedule[Clock, A, B]): IO[E, B] = {
      eff.repeat(scheduler).provide(zClock)
    }
}
Aleksandar Skrbic
@aleksandarskrbic
@VladPodilnyk Thanks, I made a workaround. Here is the full solution:
trait Scheduler2[F[_, _]] extends BootstrapRuntime {
  def repeat[E, A, B](eff: F[E, A])(schedule: Schedule[Clock, A, B]): F[E, B]
}

object Scheduler2 {
  def apply[F[+_, +_] : Scheduler2]: Scheduler2[F] = implicitly

  implicit def fromZIO: Scheduler2[IO] = new Scheduler2[IO] {
    override def repeat[E, A, B](eff: IO[E, A])(schedule: Schedule[Clock, A, B]): IO[E, B] = {
      eff.repeat(schedule).provide(environment)
    }
  }
}

object Main extends scala.App {
  val rt = Runtime.default
  implicit val a: Layer[Nothing, Clock] = Clock.live

  def repeatEffectTF[F[+_, +_]: IO2: Scheduler2]: F[Nothing, Long] =
    Scheduler2[F].repeat(F.sync(println("Effect TF")))(Schedule.spaced(3.second))

  rt.unsafeRun(repeatEffectTF[zio.IO])
}
Aleksandar Skrbic
@aleksandarskrbic
Or solution with better syntax
scala
trait Scheduler2[F[_, _]] extends BootstrapRuntime {
  def repeat[E, A, B](eff: F[E, A])(schedule: Schedule[Clock, A, B]): F[E, B]
}

object Scheduler2 {
  def apply[F[+_, +_] : Scheduler2]: Scheduler2[F] = implicitly

  implicit def fromZIO: Scheduler2[IO] = new Scheduler2[IO] {
    override def repeat[E, A, B](eff: IO[E, A])(schedule: Schedule[Clock, A, B]): IO[E, B] = {
      eff.repeat(schedule).provide(environment)
    }
  }

  implicit class syntax[F[+_, +_]: IO2: Scheduler2, E, A, B](eff: F[E, A]) {
    def zioRepeat(schedule: Schedule[Clock, A, B]) =
      Scheduler2[F].repeat(eff)(schedule)
  }
}

object Main extends scala.App {
  val rt = Runtime.default
  implicit val a: Layer[Nothing, Clock] = Clock.live

  import Scheduler2.syntax

  def repeatEffectTF[F[+_, +_]: IO2: Scheduler2]: F[Nothing, Long] =
    Scheduler2[F].repeat(F.sync(println("Effect TF")))(Schedule.spaced(3.second))

  def repeatEffectTF2[F[+_, +_]: IO2: Scheduler2]: F[Nothing, Long] =
    F.sync(println("Effect TF")).zioRepeat(Schedule.spaced(3.second))

  rt.unsafeRun(repeatEffectTF2[zio.IO])
}
Vladyslav
@VladPodilnyk
@aleksandarskrbic :thumbsup: :cool:
Aleksandar Skrbic
@aleksandarskrbic
Hi is there any idea why I can't import izumi as a standard sbt project in IntelliJ?
image.png
It looks like this, and this is first time I'm having this problem with IntelliJ
Aleksandar Skrbic
@aleksandarskrbic
The problem was with .idea folder which was accidentally committed I think :) I just removed it and everythong works!
Kai
@neko-kai
@aleksandarskrbic Hmm, it was committed on purpose to provide default Run sbtgen.sc actions and worked correctly before 🤔 Should work fine after 7mind/izumi#1534 I've also submitted an upstream issue https://youtrack.jetbrains.com/issue/SCL-19212
Aleksandar Skrbic
@aleksandarskrbic
@neko-kai Thanks! :)