Skip to content
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

refactor: Split config/halfstack/global contexts from root context #3154

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

achimnol
Copy link
Member

@achimnol achimnol commented Nov 27, 2024

This PR splits RootContext into three categories of contextual objects:

  • Configurations (those from etcd and local TOML files, runtime identifier like pidx)
  • Halfstack connection pools (postgres and redis)
  • Global stateful objects (event bus, background task manager, storage proxy connector, etc.)

Relationship:

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • Mention to the original issue

Copy link
Member Author

achimnol commented Nov 27, 2024

Copy link
Collaborator

@HyeockJinKim HyeockJinKim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, even if the root context is divided into substructures, the significance of refactoring diminishes if the root context is still being accessed directly.
It seems necessary to explicitly pass only the required configuration values to handlers or other modules.
Are there any tasks you are considering regarding this? @achimnol

@achimnol achimnol force-pushed the refactor/rootctx-hierarchical-init branch from 46c011a to 535e3b7 Compare January 3, 2025 09:26
@github-actions github-actions bot added area:docs Documentations comp:manager Related to Manager component size:XL 500~ LoC labels Jan 3, 2025
@achimnol
Copy link
Member Author

achimnol commented Jan 3, 2025

In my opinion, even if the root context is divided into substructures, the significance of refactoring diminishes if the root context is still being accessed directly. It seems necessary to explicitly pass only the required configuration values to handlers or other modules. Are there any tasks you are considering regarding this? @achimnol

Ultimately yes, but this PR is an interim step towards that goal.
I'd like to first signify whether the root context attributes are either configurations (c), global singletons (g), or database connection pools (h).

Each category would have different sharing scopes. For instance:

  • config: It can be shared and accessed from anywhere.
    • Later, we may need to add an interface to reload/live-update the config values using etcd watch for the shared configs.
  • halfstack: We need to first complete Refactoring from higher layers based on Protocols #3183 to categorize and make explicit dependency relationships between the global singletons whether each instance belongs to either service or repository layers. We may need to split existing classes to achieve this. Once we have a clear separation between the service and repository layers, global singletons in the repository layer could share the entire halfstack connection pools.
  • global: We need to pass exactly required ones.

I think introducing an explicit hierarchy to the root context will help us to automatically replace the references across the entire manager codebase after #3183.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:docs Documentations comp:manager Related to Manager component size:XL 500~ LoC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor RootContext to explicitly distinguish context info groups
2 participants