Feat triggers v0.2.2 (#6)
All checks were successful
All checks were successful
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #6.
This commit is contained in:
25
server/triggers/global.go
Normal file
25
server/triggers/global.go
Normal file
@@ -0,0 +1,25 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user