All checks were successful
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
26 lines
580 B
Go
26 lines
580 B
Go
package triggers
|
|
|
|
import "sync"
|
|
|
|
// globalEngine holds a reference to the active trigger engine.
|
|
// Set by SetGlobalEngine at startup, used by handlers that need
|
|
// to wire triggers immediately on package install.
|
|
var (
|
|
globalMu sync.RWMutex
|
|
globalEngine *Engine
|
|
)
|
|
|
|
// SetGlobalEngine stores the engine reference for use by handlers.
|
|
func SetGlobalEngine(e *Engine) {
|
|
globalMu.Lock()
|
|
globalEngine = e
|
|
globalMu.Unlock()
|
|
}
|
|
|
|
// GlobalEngine returns the current engine, or nil.
|
|
func GlobalEngine() *Engine {
|
|
globalMu.RLock()
|
|
defer globalMu.RUnlock()
|
|
return globalEngine
|
|
}
|