Skip to content

Commit

Permalink
review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
712u3 committed Oct 17, 2023
1 parent d989963 commit de613ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
7 changes: 4 additions & 3 deletions frontik/service_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,20 @@ def __init__(
self.consul_weight_total_timeout_sec = options.consul_weight_total_timeout_sec
self.consul_weight_consistency_mode = ConsistencyMode(options.consul_weight_consistency_mode.lower())
self.consul_cache_initial_warmup_timeout_sec = options.consul_cache_initial_warmup_timeout_sec
self.weight = None
self.weight: int | None = None

async def register_service(self) -> None:
address = _get_service_address(self.options)
http_check = _create_http_check(self.options, address)
await self._async_register(address, http_check)
while True:
try:
await asyncio.sleep(options.consul_cache_backoff_delay_seconds)
await self._async_register(address, http_check)
except Exception as exc:
log.exception('Failed to register %s: %s', self.service_id, exc)

async def _async_register(self, address, http_check):
async def _async_register(self, address: str | None, http_check: dict) -> None:
index, value = await self.consul.kv.get(
f'host/{self.hostname}/weight',
wait=self.consul_weight_watch_seconds,
Expand All @@ -130,7 +131,7 @@ async def _async_register(self, address, http_check):
)
weight = _get_weight_or_default(value)
if self.weight == weight:
return weight
return

self.weight = weight
register_params = {
Expand Down
10 changes: 0 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de613ae

Please sign in to comment.