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(server): optimize reload logic #60

Merged
merged 16 commits into from
Mar 2, 2024
Merged

refactor(server): optimize reload logic #60

merged 16 commits into from
Mar 2, 2024

Conversation

shouya
Copy link
Owner

@shouya shouya commented Mar 2, 2024

The purpose of this branch is to support partial reloading.

Now we will only:

  • Only rebuild endpoints whose config changes
  • Only rebuild filters whose config changes

If an endpoint's config was untouched, we will reuse the existing endpoint. Same for any filters in the filter pipeline.

There are several benefits with this approach:

  • faster, more lightweight reload
  • less disruption to caches (e.g. http client cache)
  • the server does not need to be restarted on config change
  • open up the possibility of notifying and reporting config error to inspector-ui

Aside from some logging changes, this branch should cause no functional difference.


It's not trivial to implement this feature. Doing so requires some architectural change in the server implementation. Previously the routes are statically added to the axum::Router. Now since the endpoints can be dynamically added and removed without restarting axum server, I have to implement a custom handler depend on a global instance of current config and endpoint state.

In addition, I made a more clear separation between Error and ConfigError. Functions that are called during building the config into the service will only raise ConfigError. The trait definition for FeedFilterConfig has also been updated.

@shouya shouya merged commit 126da53 into master Mar 2, 2024
2 checks passed
@shouya shouya deleted the cached-reload branch March 2, 2024 14:00
@shouya shouya restored the cached-reload branch March 2, 2024 14:10
@shouya shouya deleted the cached-reload branch March 3, 2024 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant