Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit a6f35ae

Browse files
committed
Rename function to add_worker_to_instance_map given reduction of scope
1 parent 52b5fb2 commit a6f35ae

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

docker/configure_workers_and_start.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -370,27 +370,22 @@ def convert(src: str, dst: str, **template_vars: object) -> None:
370370
outfile.write(rendered)
371371

372372

373-
def add_worker_roles_to_shared_config(
373+
def add_worker_to_instance_map(
374374
shared_config: dict,
375375
worker_name: str,
376376
worker_port: int,
377377
) -> None:
378-
"""Given a dictionary representing a config file shared across all workers,
379-
append appropriate worker information to it for the current worker_type instance.
378+
"""
379+
Update the shared config map to add the worker in the instance_map.
380380
381381
Args:
382382
shared_config: The config dict that all worker instances share (after being
383383
converted to YAML)
384384
worker_name: The name of the worker instance.
385385
worker_port: The HTTP replication port that the worker instance is listening on.
386386
"""
387-
# The instance_map config field marks the workers that write to various replication
388-
# streams
389387
instance_map = shared_config.setdefault("instance_map", {})
390388

391-
# Add all workers to the `instance_map`
392-
# Technically only certain types of workers, such as stream writers, are needed
393-
# here but it is simpler just to be consistent.
394389
if os.environ.get("SYNAPSE_USE_UNIX_SOCKET", False):
395390
instance_map[worker_name] = {
396391
"path": f"/run/worker.{worker_port}",
@@ -808,8 +803,10 @@ def generate_worker_files(
808803
else:
809804
healthcheck_urls.append("http://localhost:%d/health" % (worker_port,))
810805

811-
# Update the shared config with sharding-related options if necessary
812-
add_worker_roles_to_shared_config(shared_config, worker_name, worker_port)
806+
# Add all workers to the `instance_map`
807+
# Technically only certain types of workers, such as stream writers, are needed
808+
# here but it is simpler just to be consistent.
809+
add_worker_to_instance_map(shared_config, worker_name, worker_port)
813810

814811
# Enable the worker in supervisord
815812
worker_descriptors.append(worker_config)

0 commit comments

Comments
 (0)