-
Notifications
You must be signed in to change notification settings - Fork 46
feat: support global OS prefix #922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -81,13 +81,17 @@ class BaseOSDB(metaclass=ABCMeta): | |||||
| @abstractmethod | ||||||
| def index_name(self, vo: str, doc_id: int) -> str: ... | ||||||
|
|
||||||
| def __init__(self, connection_kwargs: dict[str, Any]) -> None: | ||||||
| def __init__( | ||||||
| self, connection_kwargs: dict[str, Any], *, global_prefix: str = "" | ||||||
| ) -> None: | ||||||
| self._client: AsyncOpenSearch | None = None | ||||||
| self._connection_kwargs = connection_kwargs | ||||||
| # We use a ContextVar to make sure that self._conn | ||||||
| # is specific to each context, and avoid parallel | ||||||
| # route executions to overlap | ||||||
| self._conn: ContextVar[bool] = ContextVar("_conn", default=False) | ||||||
| if global_prefix: | ||||||
| self.index_prefix = f"{global_prefix}_{self.index_prefix}" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on what's already in DIRAC:
Suggested change
|
||||||
|
|
||||||
| @classmethod | ||||||
| def available_implementations(cls, db_name: str) -> list[type[BaseOSDB]]: | ||||||
|
|
||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How complex would it be to add a unit test against the mock OS DB?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test can only be limited to making sure it is propagated to some extend but yes, I'll do so |
Uh oh!
There was an error while loading. Please reload this page.