osrd
osrd copied to clipboard
Split editoast into separate crates Part 1
Motivation
- (re-)compile time should be lower
- linting should be faster
- improve modularity
- better definition of the responsibility of each part of the code (no schema should interact with db for example)
- maybe launch less tests (for the crates which are last in the dependency tree)
The goal
Have at least the crates:
-
schemas
(railjson / trainschedule / rolling stock, we may split this crate in 3 later) -
osm-to-railjson
(the module becomes a crate) -
models
(tables.rs goes in there, all interaction with db belongs there) -
infra-cache
(module becomes a crate, we will have to create schemas specifically for this crate (we do not necessarily need the details of all structs for the cache) -
generated-objects
(layers / tiles / search tables / infra errors)(the SQL queries should move in `models) - ~~search engine~~ maybe later, since this module should be the first to get incremental computations, and refactors would overlap)
-
core-client
(everythingcore
-related goes in there, including schemas) -
osrd-containers
: Should contains utilities structs (NonBlankString
,RangeMap
...) Dependency diagram: https://drive.google.com/file/d/13tNMgP-Pi6EUz94C9-I0HJTNKXwJT5ry/view?usp=sharing
The goal is also:
- In src/ have a binary ediotast which only the cli, and an editoast library which holds the rest and is imported in the binary
- remove "manual" db requests everywhere
- stop using mod.rs files (thus have files like <module_name>.rs)
nice to have
- a
server
crate which contains everything actix related ?-
main
crate would only contain cli
-
If necessary to further improve compilation time:
- Split the
main
crate into different buisness components (rollin stocks / infra / train schedules)
May be problems
- EditoastError: we should implement the trait only in
main
crate, when we import the custom crate errors- This is linked to #6396 , this other refacto could be done at the same time.
Implementation plan
For each "crate-to-be" move the editoastError dependency in a first PR, then make it an actual crate in a second PR Move (in order of dependencies)
Part 1
Step 1
- [ ]
editoast_common
(renamed fromosrd_containers
) #7067
Step 2 (may be done in parallel)
- [ ]
editoast_schemas
#7048 - [ ] https://github.com/osrd-project/osrd/issues/6980 (needed for
editoast_models
)
Step 3 (may be done in parallel)
- [ ]
editoast_models
#7135 - [ ]
editoast_core_client
- [ ]
osm_to_railjson
Part 2
-
infra_cache
-
object_generation
-
editoast_cli
/editoast
(split the CLI with the rest of the app)
Acceptance criteria
- [ ] it compiles
- [ ] minimal interfaces between crates
- [ ] ediotastError only appears in the
main
crate - [ ] No functionality was lost
- [ ] New crates are well documented