-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96dcc6f
commit e396035
Showing
5 changed files
with
22 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 6 additions & 12 deletions
18
node/src/main/scala/com/wavesplatform/settings/FeaturesSettings.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
package com.wavesplatform.settings | ||
|
||
import pureconfig.* | ||
import pureconfig.generic.semiauto.deriveReader | ||
|
||
case class FeaturesSettings(autoShutdownOnUnsupportedFeature: Boolean, supported: List[Short] = defaultSupported) | ||
case class FeaturesSettings(autoShutdownOnUnsupportedFeature: Boolean, supported: List[Short] = List.empty) | ||
|
||
object FeaturesSettings { | ||
// Note: This setup (default values + manual ConfigReader instance) | ||
// is a workaround for `pureconfig-generic-scala3` (it doesn't support default values from case classes yet) | ||
val defaultSupported: List[Short] = List.empty | ||
|
||
given ConfigReader[FeaturesSettings] = ConfigReader.fromCursor(cur => | ||
for { | ||
objCur <- cur.asObjectCursor | ||
autoShutdownOnUnsupportedFeature <- objCur.required[Boolean]("auto-shutdown-on-unsupported-feature") | ||
supported <- objCur.optionalWithDefault("supported", defaultSupported) | ||
} yield FeaturesSettings(autoShutdownOnUnsupportedFeature, supported) | ||
) | ||
// This given is required for default args to work. | ||
// Details: https://github.com/pureconfig/pureconfig/issues/1673 | ||
// Note: the proposed approach with `extension` doesn't work. | ||
given ConfigReader[FeaturesSettings] = deriveReader | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters