Skip to content

Commit

Permalink
Implemented locality weighted load balancing ( tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
nastassia-dailidava committed Jan 17, 2024
1 parent 1008e9a commit 918ccd5
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import pl.allegro.tech.servicemesh.envoycontrol.consul.services.ConsulServiceCha
import pl.allegro.tech.servicemesh.envoycontrol.consul.services.ConsulServiceMapper
import pl.allegro.tech.servicemesh.envoycontrol.consul.services.NoOpServiceWatchPolicy
import pl.allegro.tech.servicemesh.envoycontrol.consul.services.ServiceWatchPolicy
import pl.allegro.tech.servicemesh.envoycontrol.logger
import pl.allegro.tech.servicemesh.envoycontrol.server.NoopReadinessStateHandler
import pl.allegro.tech.servicemesh.envoycontrol.server.ReadinessStateHandler
import pl.allegro.tech.servicemesh.envoycontrol.services.ClusterStateChanges
Expand All @@ -49,6 +50,10 @@ class ControlPlaneConfig {
Schedulers.enableMetrics()
}

companion object {
private val logger by logger()
}

@Bean
@ConfigurationProperties("envoy-control")
fun envoyControlProperties() = EnvoyControlProperties()
Expand Down Expand Up @@ -168,8 +173,10 @@ class ControlPlaneConfig {
return EnvoyHttpFilters.defaultFilters(properties.envoy.snapshot)
}

fun localDatacenter(properties: ConsulProperties) =
ConsulClient(properties.host, properties.port).agentSelf.value?.config?.datacenter ?: "local"
fun localDatacenter(properties: ConsulProperties): String {
return (ConsulClient(properties.host, properties.port).agentSelf.value?.config?.datacenter ?: "local")
.also { logger.info("Resolved local datacenter name: $it") }
}

fun controlPlaneMetrics(meterRegistry: MeterRegistry) =
DefaultEnvoyControlMetrics(meterRegistry = meterRegistry).also {
Expand Down

0 comments on commit 918ccd5

Please sign in to comment.