rksm / hot-lib-reloader-rs

Reload Rust code without app restarts. For faster feedback cycles.
MIT License
577 stars 21 forks source link

Added loaded library name templating #33

Closed CryoMyst closed 6 months ago

CryoMyst commented 9 months ago

Draft PR fixing my issue #32 where I have multiple processes hot reloading the same file causing conflicts. Will match and use old naming scheme when not specified. I have added a few different template values including uuid and rand (Which is an added dependency so I understand removing these). Definitely not great at rust so there might be some mistakes here as I was just trying to get something working at the time.

Example of the macro usage

#[hot_lib_reloader::hot_module(
    loaded_lib_name_template = "{lib_name}_hot_{pid}_{load_counter}"
)]
CryoMyst commented 9 months ago

TODO: Add some tests/docs associated with this.

rksm commented 8 months ago

Looks good to me. What's the reason to have both rand and uuid? Wouldn't one of them be sufficient?

CryoMyst commented 8 months ago

@rksm Honestly I was experimenting as to which one I wanted, technically the {pid} should cover my use cases anyway. I am not confident with rusts conditional compilation stuff however I think I have made changes to have both of those as optional features so downstream libraries/binaries have no requirement to include them.

CryoMyst commented 8 months ago

And some docs.

CryoMyst commented 8 months ago

We can remove both of those if you so wish. Maybe there is a case where the pid is the same when it's loading from a network share between 2 computers.

rksm commented 6 months ago

Thank you once again for these changes. Sorry that it took me so long, it is merged now. Cheers!