2.1 KiB
2.1 KiB
Backend internal interview (rust)
CHANGES: fixed branch
- Moving from HashMap to BTreeMap to preseve loading lines order, nevertheless still looks very cumbersome.
- Fix lines parser in Maps metrics and in aggregated_metrics to be handled properly.
- Fix unwrap / expect for obvious reasons, add simple error message via map_err, unwrap_or_else and closure function.
- Fix some source code lines order, output format and conversions.
- Change some iterators to functional mode.
- Separate tasks to independent funtions for better isolation, less responsibilities and help on tests handling.
- Adding output_path to help on result output options.
- Adding elapsed time to show how many millisecods took each metric file and total processing.
- Create type alias to make so long Map types more readable.
- Create a MetricLine struct to make parser easier (a lot of work should be done but requires full refactoring).
- Adding input_2.txt to process multiple metrics in parallel (done via std::threads), collect result properly via channels (std:mpsc) and show then properly.
- Create a generate_metrics to process each metric file and to be used in test_expected_metrics
- Following unit tests are implemented:
- test_load_input test load input file input.txt.
- test_invalid_line_value test use invalid value in line parsing.
- test_invalid_line test use invlid value in line parsing.
- test_expected_metrics test load input data from input.txt compare with output_expected.txt.
Note
Code simply works as expected trying to be preserve initial approach and not too much disruptive changes.
It is able to process multiple metrics in parallel (input.txt and input_2.txt).
A full refactoring has to be done for better quality, maintenance and be more readable. (Structs, implementaitions, settings for multiple inputs, etc).
Next round in: Improve branch