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

Commit 5c16c33

Browse files
authored
Allow modules to retrieve server and worker names (#11868)
Fixes #10701
1 parent 64ec45f commit 5c16c33

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

changelog.d/11868.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow modules to retrieve the current instance's server name and worker name.

synapse/module_api/__init__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,32 @@ def email_app_name(self) -> str:
401401
"""
402402
return self._hs.config.email.email_app_name
403403

404+
@property
405+
def server_name(self) -> str:
406+
"""The server name for the local homeserver.
407+
408+
Added in Synapse v1.53.0.
409+
"""
410+
return self._server_name
411+
412+
@property
413+
def worker_name(self) -> Optional[str]:
414+
"""The name of the worker this specific instance is running as per the
415+
"worker_name" configuration setting, or None if it's the main process.
416+
417+
Added in Synapse v1.53.0.
418+
"""
419+
return self._hs.config.worker.worker_name
420+
421+
@property
422+
def worker_app(self) -> Optional[str]:
423+
"""The name of the worker app this specific instance is running as per the
424+
"worker_app" configuration setting, or None if it's the main process.
425+
426+
Added in Synapse v1.53.0.
427+
"""
428+
return self._hs.config.worker.worker_app
429+
404430
async def get_userinfo_by_id(self, user_id: str) -> Optional[UserInfo]:
405431
"""Get user info by user_id
406432

0 commit comments

Comments
 (0)