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

Allow modules to retrieve server and worker names #11868

Merged
merged 2 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/11868.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow modules to retrieve the current instance's server name and worker name.
26 changes: 26 additions & 0 deletions synapse/module_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,32 @@ def email_app_name(self) -> str:
"""
return self._hs.config.email.email_app_name

@property
def server_name(self) -> str:
"""The server name for the local homeserver.

Added in Synapse v1.53.0.
babolivier marked this conversation as resolved.
Show resolved Hide resolved
"""
return self._server_name

@property
def worker_name(self) -> Optional[str]:
"""The name of the worker this specific instance is running as per the
"worker_name" configuration setting, or None if it's the main process.

Added in Synapse v1.53.0.
"""
return self._hs.config.worker.worker_name

@property
def worker_app(self) -> Optional[str]:
"""The name of the worker app this specific instance is running as per the
"worker_app" configuration setting, or None if it's the main process.

Added in Synapse v1.53.0.
"""
return self._hs.config.worker.worker_app

async def get_userinfo_by_id(self, user_id: str) -> Optional[UserInfo]:
"""Get user info by user_id

Expand Down