tl;dr:
Thread Safety!
Hey everyone! It’s been a busy and exciting week, and I'm thrilled to share the latest progress. I hit a major milestone that I know many of you have been waiting for.
The Big One: Thread Safety
The headline feature this week is that the Catalog is now fully thread-safe. This has been a huge personal goal for the project for a while, and it’s finally here!
What does this mean for you? You can now wrap the Catalog in an Arc and share it across different threads without needing to wrap it in a Mutex or RwLock yourself. This is perfect for scenarios like web servers, data processing pipelines, or any application that uses concurrency.
To make this happen, I changed methods like upsert and persist to no longer require a mutable &mut self reference. They now operate on an immutable &self reference, handling the internal locking for you. As part of this, I've added a new suite of tests specifically designed to ensure everything is thread-safe and to prevent future regressions.
API Refinements and Housekeeping
Achieving thread safety had a few ripple effects, which gave me a great opportunity to do some house-cleaning.
First, I went through and restored the library examples, which needed updating after the API changes for thread safety. They should all be working again and serve as a good reference for the new patterns.
I also took a moment to review the public API for the entities. I’ve made the internal fields private to improve encapsulation. You can still get everything you need, like the id, through public methods. This makes the API safer and clearer to use.
Beyond that, I spent time on general project health:
- Better Test Organization: I extracted all the SQLite tests into their own dedicated module. This makes the codebase cleaner and easier to navigate.
- Improved Documentation: I put in a solid effort to update the documentation, pushing the test coverage numbers higher. I also added a build warning that will let me know if I forget to document new public items in the future.
- Bug Fixes: I squashed a couple of pesky bugs, including one where I was calling the wrong method to get an entity ID and another related to setting the correct mutability level on a call.
It was a really productive week. Making the Catalog thread-safe is a huge step forward for the project, and I'm really happy with the API and code quality improvements that came along with it.
Thanks for following my progress. As always, feel free to grab the latest version and let me know what you think
Chore
- add warning for missing documentation
- extract tests from sqlite_* files into their own module
- restore examples after thread safety feature
- restore lib example after thread safety feature
Doc
- update documentation to reach higher coverage
Feat
- set catalog as thread safe
Fix
- call proper method to get entity id
- set proper mutability level for with_items call
Review
- make entity fields private; expose id and subclass
Test
- add test for thread safety; remove mut for upsert and persist
Wip
- add test for thread safety
tags: #rust, #devlog, #project:heave