I'm trying to create a global HashMap that on program startup will loop through a directory finding tantivy indexes and if they open will store a writer and reader for the indexes in the map.
All requests coming in then check the map to see if the index exists and if so creates a searcher off the reader or uses the writer.
I'm struggling to find a way to do this in rust. I'm assuming I need to create a HashMap and wrap it in a Mutex and Arc so its thread safe to access it. like this.
let index_map = Arc::new(Mutex::new(HashMap::new()));
But no idea how to make it global or if this is the rust way of doing this, would creating a single thread that does this and then use channels to communicate to it be better ?