by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Bogdan Roman
    @bogdanromanx
    @neko-kai many thanks for the pointers and the PR, it’s really useful! ;)
    Stan Sobolev
    @Jacke

    Hey guys, I new in BIO and I need assistance.

    I have

    def t[F[+_,+_]: BIOPrimitives: BIO : BIOApplicative, R[_] : Sync : MonadError[?[_], Throwable], B](t: R[B]): F[Throwable, Int] = ??? // How to get F[_,_] from R (which is cats effect IO instance)
    
    to be able to do something like this
    t(IO(1/0)) 
    // zio.IO[Throwable, Int]
    Kai
    @neko-kai
    @Jacke If R[_] is a different type that isn't F[Throwable, ?], you could do it like this:
    def t[F[+_, +_]: BIOAsync: BIOFork, R[_]: Effect, B](t: R[B]): F[Throwable, B] = {
      import Izumi.functional.bio.catz._
      Concurrent[F[Throwable, ?]].liftIO(Effect[R].toIO(t))
    }
    Stan Sobolev
    @Jacke
    yes, perfect
    thanks
    Kai
    @neko-kai
    :+1:
    Stan Sobolev
    @Jacke

    @Kai I getting:

    @ t(IO(1))
    cmd30.sc:1: type mismatch;
     found   : izumi.functional.bio.PredefinedHelper.Predefined.Of[izumi.functional.bio.BIOAsync3[zio.ZIO]]
        (which expands to)  izumi.functional.bio.BIOAsync3[zio.ZIO]{type IsPredefined = izumi.functional.bio.PredefinedHelper.Predefined}
     required: izumi.functional.bio.BIOAsync[[+E, +A]zio.ZIO[R,E,A]]
        (which expands to)  izumi.functional.bio.BIOAsync3[[-R, +E, +A]zio.ZIO[R,E,A]]
    val res30 = t(IO(1))

    Is there any workaround?

    Kai
    @neko-kai
    @Jacke Does it work if you specify the types explicitly? e.g. t[zio.IO, cats.effect.IO](cats.effect.IO(1))
    If you’re on 2.12 you might also be missing compiler options, you need these sbt settings for BIO to work on 2.12:
    scalacOptions += "-Ypartial-unification"
    scalacOptions += "-Xsource:2.13”
    Stan Sobolev
    @Jacke

    No, it's not

    @ t[zio.IO, cats.effect.IO](cats.effect.IO(1))
    cmd30.sc:1: wrong number of type parameters for method t: [F[+_, +_], R[_], B](t: R[B])(implicit evidence$1: izumi.functional.bio.BIOAsync[F], implicit evidence$2: izumi.functional.bio.BIOFork[F], implicit evidence$3: izumi.functional.bio.BIO[F], implicit evidence$4: cats.effect.Effect[R], implicit cs: cats.effect.ContextShift[R])F[Throwable,B]
    val res30 = t[zio.IO, cats.effect.IO](cats.effect.IO(1))
                 ^
    Compilation Failed

    I'm on 2.13.2 and it still very strange :]

    Kai
    @neko-kai
    t[zio.IO, cats.effect.IO, Int](cats.effect.IO(1))
    Stan Sobolev
    @Jacke

    Cool

    @ t[zio.IO, cats.effect.IO, Int](cats.effect.IO(1))
    res30: zio.package.IO[Throwable, Int] = zio.ZIO$EffectPartial@3c6e3104

    Oh, language things :)

    Kai
    @neko-kai
    @umbreak @bogdanromanx There’s just been a new release with pretty significant QoL improvements for both distage-testkit & distage-framework-docker - https://github.com/7mind/izumi/releases/tag/v0.10.9 - should make memoization behavior far better & more consistent within your project (and make it obvious through logs). Note: you can now turn off all logging incl. config loading in testkit by setting TestConfig#logLevel
    Bogdan Roman
    @bogdanromanx
    fantastic, thanks @neko-kai
    Stan Sobolev
    @Jacke

    Hey guys, I have another problem, I'm trying to use cats.IO resource in MainPlugin,
    but I getting this error

        Suppressed: izumi.distage.model.exceptions.IncompatibleEffectTypesException: Incompatible effect types: Can't execute effect in `λ %0 → cats.effect.IO[+0]` which is neither Identity, nor a subtype of the effect that Provisioner was launched in: `λ %1 → zio.ZIO[-Any,+Throwable,+1]`
    
    Clarification:
      - To execute `.fromEffect` and `.fromResource` bindings for effects other than `Identity` you need to use `Injector.produceF` method with F type corresponding to the type of effects/resources you inject
      - Subtype type constructors are allowed. e.g. when using ZIO you can execute actions with type IO[Nothing, ?] when running in IO[Throwable, ?]
    
            at izumi.distage.provisioning.PlanInterpreterDefaultRuntimeImpl.$anonfun$verifyEffectType$1(PlanInterpreterDefaultRuntimeImpl.scala:215)
            at izumi.distage.model.effect.DIEffect.$anonfun$traverse_$2(DIEffect.scala:44)
            at zio.internal.FiberContext.evaluateNow(FiberContext.scala:844)
            ... 19 more
    Caused by: zio.Cause$FiberTrace: Fiber failed.

    That's because

          make[Transactor[F[Throwable, ?]]].fromResource[TransactorResource[F[Throwable, ?]]]

    I can make this with zio.IO, but if I do

          //make[Transactor[R]].fromResource[TransactorResourceCats[R]]
    where R == cats.IO

    I got the error from above.
    Is it possible to get cats.IO Resource effect with IO{], rather then with F[,_]: TagKK : BIO?

    Kai
    @neko-kai

    @Jacke Yes, but you will need to move all other components to cats.effect.IO too. To change the effect type

    1. in app: change the RoleAppLauncher's effect in https://github.com/7mind/distage-example/blob/develop/src/main/scala/leaderboard/LeaderboardRole.scala#L121 - inherit from RoleAppLauncher.LauncherF[cats.effect.IO] instead of LauncherBIO[zio.IO]

    2. in tests change the testkit's effect in https://github.com/7mind/distage-example/blob/develop/src/test/scala/leaderboard/tests.scala#L14 - inherit from DistageSpecScalatest[cats.effect.IO] instead of DistageBIOEnvSpecScalatest[zio.IO]

    3. When using Injector directly, not via distage-framework or distage-testkit, the effect type is determined by the type parameter passed to Injector#produceF/#produceRunF/#produceGetF etc

    You will need to move all components to the new effect type, only one effect type can be used at a time.

    Stan Sobolev
    @Jacke
    Got it, thank you very much
    Stan Sobolev
    @Jacke

    Hi guys, i'm trying to use injector directly via:

    
    val myModules = CatsAppPlugin.modules.app[IO] ++ 
                    CatsAppPlugin.modules.repoProd[IO] ++ 
                    CatsModule ++
                    CatsAppPlugin.modules.configs ++
                    CatsAppPlugin.modules.api[IO] ++
                    CatsAppPlugin.modules.repoDummy[IO]
    
    val plan      = Injector().plan(myModules, Roots.Everything)
    var ctx: Module[IO]  = Injector().produce(myModules, Roots.Everything).unsafeGet().get[Module[IO]]

    but I got an error

    com.spread0x.http4s.service.UserServiceSpec *** ABORTED ***
      izumi.distage.model.exceptions.ProvisioningException: Provisioner stopped after 1 instances, 5/64 operations failed:
     - {type.izumi.distage.config.model.AppConfig} (CatsAppPlugin.scala:162), MissingInstanceException: Instance is not available in the object graph: {type.izumi.distage.config.model.AppConfig}.
    Required by refs:
     * {type.com.spread0x.config.PostgresCfg}
     * {type.com.spread0x.config.PostgresPortCfg}
     * {type.com.spread0x.config.ServerConfig}

    How can I inject izumi.distage.config.model.AppConfig to fix the error?

    Corey O'Connor
    @coreyoconnor
    @Jacke one option:
    import com.typesafe.config.ConfigFactory
    import izumi.distage.config.AppConfigModule
    
    val myModules = AppConfigModule(ConfigFactory.defaultApplication) ++ ...
    Stan Sobolev
    @Jacke
    Does it works only with ZIO? I got multiple errors with cats (I set every type paremeter of my modules to [cats.effect.IO]):
    com.spread0x.http4s.http.UserRoutesSpec *** ABORTED ***
      izumi.distage.model.exceptions.ProvisioningException: Provisioner stopped after 1 instances, 4/65 operations failed:
     - {type.org.http4s.client.Client[=λ %0 → IO[+0]]} (CatsAppPlugin.scala:86), IncompatibleEffectTypesException: Incompatible effect types: Can't execute effect in `λ %0 → cats.effect.IO[+0]` which is neither Identity, nor a subtype of the effect that Provisioner was launched in: `λ %0 → 0`
    Stan Sobolev
    @Jacke

    Ops, I solved it by produceF

    Injector().produceF[IO](myModules, Roots.Everything).unsafeGet().map(_.get[Module[IO]]).unsafeRunSync

    works well, thanks

    vonchav
    @voonchav_gitlab
    Hi @neko-kai , any plan to upgrade LogStage to ZIO RC21? :)
    Kai
    @neko-kai
    @voonchav_gitlab Not sure, due to upstream regressions: zio/zio#3851 Did you check if there’s a binary compatiblity error with logstage & RC21? It may just work with the update if the binary breakage didn’t touch the methods used in logstage.
    vonchav
    @voonchav_gitlab
    @neko-kai I haven't tried upgrading to zio rc21 cuz I'm waiting for other libs to upgrade. But I can definitely try upgrading to rc21 with current version of logstage. Thanks!
    vonchav
    @voonchav_gitlab
    @neko-kai Looks like that issue has been fixed and a rc21-1 is on the way :)
    Kai
    @neko-kai
    @voonchav_gitlab Yup, will release an update soon
    vonchav
    @voonchav_gitlab
    Awesome, thanks!
    Kai
    @neko-kai
    @voonchav_gitlab just tagged 0.10.16 for zio-rc21-2
    vonchav
    @voonchav_gitlab
    Thank you, sir! :)
    Anton Solovyev
    @Rosteelton

    Hi all! I would like to ask about logstage with logback configuration.
    Now I have json log in %msg field with this setting: LogSinkLegacySlf4jImpl(LogstageCirceRenderingPolicy()).
    Is there some way to convert other slf4j logs (from other libraries) to logstage format to work with logback?

    Or maybe you can tell me another way to use logstage api for json rendering with logback template

    Paul S.
    @pshirshov

    Is there some way to convert other slf4j logs (from other libraries) to logstage format to work with logback?

    You mean a way to make slf4j messages structure? Nope

    In case you just wish to forward slf4j messages into logstage queue - use slf4j adaptor

    Or maybe you can tell me another way to use logstage api for json rendering with logback template

    I'm not sure what exactly you want to do. We have logstage-sink-slf4j which dumps logstage messages into slf4j. You may use it as a reference and implement your own logstage -> logback adapter

    We also have logstage-adapter-slf4j which works as an slf4j backend and forwards sl4j->logstage

    You can't magically make slf4j messages structured
    You may write logstage messages into logback, but you'll have to write some code. We didn't do that because we don't need that but we would welcome your contribution
    @Rosteelton
    truongio
    @truongio
    Hi! One of our projects is using LogStage for logging. I'm trying to find out if there is some easy way to make it work well with Google Cloud Logging (https://cloud.google.com/logging/docs/setup/java). In our other services we have a logback.xml file with the configuration structure. Does LogStage have any support for this?
    Kai
    @neko-kai
    @truongio Hi, you can use logstage-sink-slf4j to redirect LogStage to Slf4j
    
      // Router from LogStage to Slf4J
      "io.7mind.izumi" %% "logstage-sink-slf4j " % "0.10.16",
    slf4j is usually backed by logback.
    You may also write a custom LogSink with google cloud logging APIs