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 ArticleCached into separate struct #45

Open
AlexMikhalev opened this issue Feb 15, 2024 · 3 comments
Open

Refactor ArticleCached into separate struct #45

AlexMikhalev opened this issue Feb 15, 2024 · 3 comments
Labels
good first issue Good for newcomers

Comments

@AlexMikhalev
Copy link
Contributor

@mre in PR review: The one downside I see with making articles_cached a part of ConfigState is that we couple two separate concerns together: configuration handling and article handling. Do we always need both in all places? If the answer is no, then they shouldn't be coupled on that level. 😉 (To make that clearer, ConfigState could be renamed to ConfigSync to indicate that it is just a Sync version of Config.)

I think we should keep those two things separate.

If we need to couple them somehow, I would maybe introduce a new higher-level struct like State { config_state, cached_articles }
or introduce a Cache struct, which holds the cached articles: Cache { articles }.

I think this will make testing easier.

@AlexMikhalev
Copy link
Contributor Author

I want to see ArticleCached as a separate struct with persistable methods - new/save/load, started on it and then abandoned: both axum and tauri expect a single global state passed with API calls, so even when we separate config_state and cached_articles, we will have to pass both via a single State.
Use case: As a user, I shall be able to add articles to the index via Axum server API and retrieve both the index and article cached in the search output.

This leads to the following requirements:

  1. Index calls parse_document for each role but shall only add articles into the cache once
  2. Not only ArticlesCashed shall be persistables, but we need to persist snapshots of RoleGraph or, better, re-build rolegraphs for each role on loading ArticlesCached

@mre
Copy link
Contributor

mre commented Feb 15, 2024

Yes, fair point. Then let's have a structure like this:

struct State {
  config: ConfigState,
  articles: Thesaurus,
}

which is essentially

struct State {
  config: ConfigState,
  articles: AHashMap<String, Article> = AHashMap::new(),
}

Then we can still keep the config and the cache separate, while passing the object to axum/tauri.
What do you think?

@AlexMikhalev
Copy link
Contributor Author

Thesaurus is different - it's "index" using knowledge graphs attached to the role per config. I think this one:

struct State {
  config: ConfigState,
  articles: AHashMap<String, Article> = AHashMap::new(),
}

for axum will be ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants