Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to call liveZIO? #388

Closed
SimunKaracic opened this issue Jan 17, 2023 · 2 comments
Closed

How to call liveZIO? #388

SimunKaracic opened this issue Jan 17, 2023 · 2 comments

Comments

@SimunKaracic
Copy link

This is more of a question than an issue.
The docs show us the following way of building credentials:

// build S3 Layer from default available credentials providers
val s3: Layer[S3Exception, S3] = liveZIO(Region.AF_SOUTH_1, default)

However, this doesn't result in a Layer[S3Exception, S3], it returns a ZLayer[zio.Scope, S3Exception, S3]

I get the following error, for example:

type mismatch;
 found   : zio.ZLayer[zio.Scope,software.amazon.awssdk.services.s3.model.S3Exception,zio.s3.S3]
 required: zio.Layer[software.amazon.awssdk.services.s3.model.S3Exception,zio.s3.S3]
    (which expands to)  zio.ZLayer[Any,software.amazon.awssdk.services.s3.model.S3Exception,zio.s3.S3]
Error occurred in an application involving default arguments.
  def live2: Layer[S3Exception, S3] = liveZIO(Region.AF_SOUTH_1, default)

What should I do? Call liveZIO[Any] (which is the only thing I can think of that let's me compile this code)? What do I need to provide here?

@regis-leray
Copy link
Member

Scope is provided by default by the runtime of ZIO 2.x

Which version of zio are you using ? Can you please provide the full snippet of code for your example ?

👇 i think there is a mistake in the current implementation, i need to remove the constraints for
provider: RIO[R with Scope, AwsCredentialsProvider] should be provider: RIO[R, AwsCredentialsProvider]

  def liveZIO[R](
    region: Region,
    provider: RIO[R with Scope, AwsCredentialsProvider],
    uriEndpoint: Option[URI] = None
  ): ZLayer[R, S3Exception, S3] = ???
    

@regis-leray
Copy link
Member

regis-leray commented Jan 18, 2023

How to use it, with default provider

https://github.com/zio/zio-s3/blob/series/2.x/zio-s3/src/test/scala/zio/s3/S3Test.scala#L44

val s3: ZLayer[Scope, S3Exception, S3] =
      zio.s3.liveZIO(Region.EU_CENTRAL_1, zio.s3.providers.default)

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

No branches or pull requests

2 participants