1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-08 20:41:57 +00:00

context transactions removed and make Context.Domain customizable as requested

This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-06-05 06:15:10 +03:00
parent c6911851f1
commit d8af2a1e14
8 changed files with 28 additions and 313 deletions

View File

@@ -7,15 +7,30 @@ import (
"syscall"
)
// RegisterOnInterrupt registers a global function to call when CTRL+C/CMD+C pressed or a unix kill command received.
// RegisterOnInterrupt registers a global function to call when CTRL+C pressed or a unix kill command received.
func RegisterOnInterrupt(cb func()) {
// var cb func()
// switch v := callbackFuncOrFuncReturnsError.(type) {
// case func():
// cb = v
// case func() error:
// cb = func() { v() }
// default:
// panic(fmt.Errorf("unknown type of RegisterOnInterrupt callback: expected func() or func() error but got: %T", v))
// }
Interrupt.Register(cb)
}
// Interrupt watches the os.Signals for interruption signals
// and fires the callbacks when those happens.
// A call of its `FireNow` manually will fire and reset the registered interrupt handlers.
var Interrupt = new(interruptListener)
var Interrupt TnterruptListener = new(interruptListener)
type TnterruptListener interface {
Register(cb func())
FireNow()
}
type interruptListener struct {
mu sync.Mutex