Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Commit

Permalink
Rename AdminClient.fromManagedJavaClient to `AdminClient.fromScoped…
Browse files Browse the repository at this point in the history
…JavaClient` to follow ZIO2 conventions && Remove "Managed" from documentation (#117)
  • Loading branch information
guizmaii committed Dec 20, 2022
1 parent d0e7068 commit 53e3013
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ If you require more control over the consumption process, read on!
First, create a consumer using the ConsumerSettings instance:

```scala
import zio.Clock, zio.ZLayer, zio.ZManaged
import zio.*
import zio.kafka.consumer.{ Consumer, ConsumerSettings }

val consumerSettings: ConsumerSettings = ConsumerSettings(List("localhost:9092")).withGroupId("group")
val consumerManaged: ZIO[Scope, Throwable, Consumer] =
val consumerScoped: ZIO[Scope, Throwable, Consumer] =
Consumer.make(consumerSettings)
val consumer: ZLayer[Clock, Throwable, Consumer] =
ZLayer.scoped(consumerManaged)
ZLayer.scoped(consumerScoped)
```

The consumer returned from `Consumer.make` is wrapped in a `ZLayer`
Expand Down
9 changes: 4 additions & 5 deletions zio-kafka/src/main/scala/zio/kafka/admin/AdminClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import org.apache.kafka.common.{
Uuid
}
import zio._

import zio.kafka.admin.acl._

import java.util.Optional
Expand Down Expand Up @@ -1405,15 +1404,15 @@ object AdminClient {
}

def make(settings: AdminClientSettings): ZIO[Scope, Throwable, AdminClient] =
fromManagedJavaClient(javaClientFromSettings(settings))
fromScopedJavaClient(javaClientFromSettings(settings))

def fromJavaClient(javaClient: JAdmin): URIO[Any, AdminClient] =
ZIO.succeed(new LiveAdminClient(javaClient))

def fromManagedJavaClient[R, E](
managedJavaClient: ZIO[R with Scope, E, JAdmin]
def fromScopedJavaClient[R, E](
scopedJavaClient: ZIO[R with Scope, E, JAdmin]
): ZIO[R with Scope, E, AdminClient] =
managedJavaClient.flatMap { javaClient =>
scopedJavaClient.flatMap { javaClient =>
fromJavaClient(javaClient)
}

Expand Down

0 comments on commit 53e3013

Please sign in to comment.