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

Commit

Permalink
Fix rebase on v2.0.4 (#122)
Browse files Browse the repository at this point in the history
Fix publishing (#124)
  • Loading branch information
guizmaii committed Jan 17, 2023
1 parent 94660b9 commit 73b3bda
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 127 deletions.
94 changes: 0 additions & 94 deletions .github/workflows/site.yml

This file was deleted.

33 changes: 8 additions & 25 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import sbt.Keys.{ fork, parallelExecution }
import scala.sys.process._

import scala.util.Try

lazy val scala212 = "2.12.17"
lazy val scala213 = "2.13.10"
lazy val scala3 = "3.2.1"
Expand Down Expand Up @@ -74,15 +79,14 @@ val excludeInferAny = { options: Seq[String] => options.filterNot(Set("-Xlint:in
lazy val root = project
.in(file("."))
.settings(
name := "zio-kafka",
publish / skip := true,
name := "zio-kafka",
publish / skip := true,
crossScalaVersions := Nil // https://www.scala-sbt.org/1.x/docs/Cross-Build.html#Cross+building+a+project+statefully
)
.aggregate(
zioKafka,
zioKafkaTestUtils,
zioKafkaTest,
docs
zioKafkaTest
)

def buildInfoSettings(packageName: String) =
Expand Down Expand Up @@ -174,24 +178,3 @@ lazy val zioKafkaTest =

addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt")
addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck")

lazy val docs = project
.in(file("zio-kafka-docs"))
.settings(
moduleName := "zio-kafka-docs",
scalacOptions -= "-Yno-imports",
scalacOptions -= "-Xfatal-warnings",
projectName := "ZIO Kafka",
mainModuleName := (zioKafka / moduleName).value,
projectStage := ProjectStage.ProductionReady,
docsPublishBranch := "master",
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(zioKafka),
readmeCredits :=
"This library is heavily inspired and made possible by the research and implementation done in " +
"[Alpakka Kafka](https://github.com/akka/alpakka-kafka), a library maintained by the Akka team and originally " +
"written as Reactive Kafka by SoftwareMill.",
readmeLicense +=
"\n\n" + """|Copyright 2021 Itamar Ravid and the zio-kafka contributors. All rights reserved.
|<!-- TODO: not all rights reserved, rather Apache 2... -->""".stripMargin
)
.enablePlugins(WebsitePlugin)
1 change: 0 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.2")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.6")
addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.3.0")
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.kafka

import zio.{Task, ZIO}
import zio.{ Task, ZIO }

import java.util.UUID

Expand Down
37 changes: 31 additions & 6 deletions zio-kafka-test-utils/src/main/scala/zio/kafka/KafkaTestUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,38 @@ object KafkaTestUtils {
def adminSettings: ZIO[Kafka, Nothing, AdminClientSettings] =
ZIO.serviceWith[Kafka](_.bootstrapServers).map(AdminClientSettings(_))

def withAdmin[T](f: AdminClient => RIO[Kafka, T]) =
def saslAdminSettings(username: String, password: String): ZIO[Kafka.Sasl, Nothing, AdminClientSettings] =
ZIO
.serviceWith[Kafka.Sasl](_.value.bootstrapServers)
.map(
AdminClientSettings(_).withProperties(
"sasl.mechanism" -> "PLAIN",
"security.protocol" -> "SASL_PLAINTEXT",
"sasl.jaas.config" -> s"""org.apache.kafka.common.security.plain.PlainLoginModule required username="$username" password="$password";"""
)
)

def withAdmin[T](f: AdminClient => RIO[Kafka, T]): ZIO[Kafka, Throwable, T] =
for {
settings <- adminSettings
fRes <- ZIO.scoped {
AdminClient
.make(settings)
.flatMap(client => f(client))
}
fRes <- withAdminClient(settings)(f)
} yield fRes

def withSaslAdmin[T](
username: String = "admin",
password: String = "admin-secret"
)(
f: AdminClient => RIO[Kafka.Sasl, T]
): ZIO[Kafka.Sasl, Throwable, T] =
for {
settings <- saslAdminSettings(username, password)
fRes <- withAdminClient(settings)(f)
} yield fRes

private def withAdminClient[R, T](settings: AdminClientSettings)(f: AdminClient => RIO[R, T]) =
ZIO.scoped[R] {
AdminClient
.make(settings)
.flatMap(client => f(client))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package zio.kafka

import zio.ZLayer
import zio.kafka.embedded.Kafka
import zio.test._

trait ZIOSpecWithSaslKafka extends ZIOSpec[TestEnvironment with Kafka.Sasl] with KafkaRandom {
override val bootstrap: ZLayer[Any, Any, TestEnvironment with Kafka.Sasl] =
Expand Down

0 comments on commit 73b3bda

Please sign in to comment.