Open ignasi35 opened 6 years ago
By "a strongly typed custom configuration instance" do you mean a custom case class, or one of those Scala wrappers of Config?
By "a strongly typed custom configuration instance" do you mean a custom case class, or one of those Scala wrappers of Config?
A custom case class.
How about mapping the settings to something like:
case class LagomAkkaDiscoveryConfigDefaults(portName: Option[String],
portProtocol: Option[String],
scheme: Option[String])
case class ServiceNameMapping(lookup: Option[String],
scheme: Option[String])
case class LagomAkkaDiscoveryConfig(defaults: LagomAkkaDiscoveryConfigDefaults,
serviceNameMappings: Map[String, ServiceNameMapping],
lookupTimeout: Duration)
(just a proposal, we should not use case class
es because of the bin compat issues)
Then:
- private[lagom] class ServiceNameMapper(config: Config) {
+ private[lagom] class ServiceNameMapper(config: LagomAkkaDiscoveryConfig) {
- private[lagom] class AkkaDiscoveryHelper(config: Config, serviceDiscovery: ServiceDiscovery)(
+ private[lagom] class AkkaDiscoveryHelper(config: LagomAkkaDiscoveryConfig, serviceDiscovery: ServiceDiscovery)(
etc...
Most of the complexity in ServiceMapper
would move away from that class into a separate Config
loading function.
AkkaDiscoveryServiceLocator
uses theConfig
from theActorSystem
. Instead, it should receive a strongly typed custom configuration instance.