Skip to content

Conversation

erikvanoosten
Copy link
Collaborator

The admin client re-defines java classes in their Scala equivalent. The scala ↔ java converters are part of these classes even though they should not be used, or even not be needed, by users of the admin client.

In this change the converter code is removed from the public API and moved to an internal package.

The converter code is still available by importing the internal package. However, please note that code in internal packages may change in any way in any zio-kafka release.

import zio.kafka.admin.internal.JavaConverters._

The admin client re-defines java classes in their Scala equivalent. The scala ↔ java converters are part of these classes even though they should not be used, or even not be needed, by users of the admin client.

In this change the converter code is removed from the public API and moved to an internal package.

The converter code is still available by importing the internal package. However, please note that code in internal packages may change in any way in any zio-kafka release.
```
import zio.kafka.admin.internal.JavaConverters._
```
Copy link
Collaborator

@svroonland svroonland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, it's cleaner this way, especially in the AdminClient.

ReplicaInfo(size = jri.size(), offsetLag = jri.offsetLag(), isFuture = jri.isFuture)
}

implicit class AclOperationAsScala(private val ao: AclOperation) extends AnyVal {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the AclOperationAsScala and JAclOperationAsJava names be switched here?

}

implicit class ListConsumerGroupsOptionsAsJava(private val lcgo: ListConsumerGroupsOptions) extends AnyVal {
def asJListGroupsOptions: JListGroupsOptions =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not asJava?

}

implicit class JTopicDescriptionAsScala(private val td: JTopicDescription) extends AnyVal {
def asScala: Try[TopicDescription] = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the Try?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was present in the refactored code.

* may be null
*/
implicit class JNodeAsScala(private val jn: JNode) extends AnyVal {
def asScala: Option[Node] =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since every java object (or scala object in fact) can be null, it would be consistent to make all asScala operations return an Option. Or not and do an Option(..).map(_.asScala) at the calling location. The second would be my preference.

}
final case class ConfigResource(`type`: ConfigResourceType, name: String)

sealed trait ConfigResourceType
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot cleaner now.

case object Subtract extends AlterConfigOpType
// noinspection SpellCheckingInspection
@deprecated(since = "3.1.0", message = "Use Subtract")
val Substract: Subtract.type = Subtract
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I often make this typo too.

@erikvanoosten
Copy link
Collaborator Author

@svroonland I propose we close this issue without merging. I like it that the code moves out of the public API, but I do not like it that this is a large refactoring without much tests, nor do I like how this adds method asScala to many many classes which makes it hard to use correctly.

@svroonland
Copy link
Collaborator

Sure, I can go along with that.

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

Successfully merging this pull request may close these issues.

2 participants