On Monday, 3 October 2016 20:55:45 UTC+3, [email protected] wrote:
>
> Hi,
>
> I m looking for a package which would call a producer when a fs event is 
> emitted. 
>

> Doing so i could reload templates everytime they changed without 
> restarting the app.
>

Based on complexity:

1. For templates, just reload from disk every time you render.

2. Use a cache, see whether the file is newer on disk -- if yes, reload... 
put a RW mutex around the table containing templates.

3. Walk the directory and filter by ext every 1s and see whether the 
largest modified date has changed... if yes, reload everything.

https://play.golang.org/p/fdGIvGGicz

To swap out the templates put a RW mutex around the templates instance and 
replace the whole thing.

4. Same as before, but track time for each file separately and for 
modifications -- gives you more information and works better when you 
checkout older code.

0. watch for changes and rebuild and restart the whole program: 
https://github.com/loov/watchrun ... most of the time I use this.

>
> I ve found this package https://github.com/gernest/hot 
> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fgernest%2Fhot&sa=D&sntz=1&usg=AFQjCNHI2Mesir4J2aa_ZclRyeA1TXg8Jg>
>
> But, its totally built to render templates, where as i know i ll add other 
> kind of resources to watch & reload.
>
> Also, i m a bit skeptic because it re-assigns a *template.Template pointer 
> from a go func, and consume it from another routine.
>
> See 
> https://github.com/gernest/hot/blob/master/hot.go#L88
> https://github.com/gernest/hot/blob/master/hot.go#L104
> https://github.com/gernest/hot/blob/master/hot.go#L162
>
> Is it safe to do so ???
>
> thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to