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

Hocon config companions #562

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Hocon config companions #562

wants to merge 1 commit into from

Conversation

sebaciv
Copy link
Contributor

@sebaciv sebaciv commented Apr 11, 2024

Add base companions for classes representing HOCON config

@sebaciv sebaciv requested a review from ddworak April 11, 2024 10:24

/**
* Use this type in data deserialized from HOCON to in order to read size in bytes represented with
* [[https://github.com/lightbend/config/blob/master/HOCON.md#size-in-bytes-format HOCON's nice representation]].
Copy link
Member

Choose a reason for hiding this comment

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

Based on this source, there are a lot more strings supported in HOCON.


import scala.concurrent.duration.*

trait CommonsHoconCodecs {
Copy link
Member

Choose a reason for hiding this comment

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

nit, naming: we already have CborOptimizedCodecs and BsonGenCodecs. Maybe we should try to stay consistent with one of those in naming (probably the latter).

Comment on lines +15 to +20
input.readCustom(ConfigValueMarker).map {
case obj: ConfigObject => obj.toConfig
case v => throw new ReadFailure(s"expected a config OBJECT, got ${v.valueType}")
}.getOrElse {
ConfigFactory.parseString(input.readSimple().readString())
},
Copy link
Member

Choose a reason for hiding this comment

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

nit: I could be convinced this is one of the rare instances where .fold looks cleaner

Comment on lines +37 to +41
implicit final val classKeyCodec: GenKeyCodec[Class[?]] =
GenKeyCodec.create(Class.forName, _.getName)

implicit final val classCodec: GenCodec[Class[?]] =
GenCodec.nullableString(Class.forName, _.getName)
Copy link
Member

Choose a reason for hiding this comment

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

What would be the use case for those in config?

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.

None yet

2 participants