Hot Reload
Current Status
The current github.com/go-juicedev/juice main branch does not expose a public hot-reload API for replacing an engine’s configuration in place.
Older documentation mentioned engine.SetConfiguration and IConfiguration, but those APIs are not present in the current codebase.
Do not rely on SetConfiguration in new code.
Recommended Approach
If mapper or configuration files change, create a new engine from the updated configuration and swap it at the application boundary. Keep the old engine alive until in-flight requests finish, then close it.
Example shape:
type EngineHolder struct {
value atomic.Value // stores *juice.Engine
}
func (h *EngineHolder) Engine() *juice.Engine {
return h.value.Load().(*juice.Engine)
}
func (h *EngineHolder) Reload(path string) error {
next, err := juice.DefaultFromFile(path)
if err != nil {
return err
}
previous := h.Engine()
h.value.Store(next)
go func() {
// Wait for your own in-flight request drain policy here.
_ = previous.Close()
}()
return nil
}
Notes
Recreating the engine also recreates database connection management according to the new configuration.
Plan request draining and rollback behavior at the application level.
For most services, restarting the process or rolling deployment is simpler and safer than ad hoc in-process hot reload.