Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(closer any)
Register takes a function and appends it to the list of functions to be called on an interrupt signal. It also sets up the listener on the first call.
The function receives a context bounded by the ServerOptions.Timeout.ShutdownOnInterruptTimeout of the running server, see RegisterWithTimeout.
func RegisterWithTimeout ¶ added in v14.0.1
RegisterWithTimeout is Register for a server's own closer, which also names how long the closers of an interrupt may take: its ServerOptions.Timeout.ShutdownOnInterruptTimeout.
Every closer of the signal receives a context carrying that as its deadline, so a callback registered with Register, iris.RegisterOnInterrupt(app.Shutdown) above all, is bounded by the same option that bounds the server's own drain. A zero or negative value sets no deadline, as that option documents, and so does a process whose servers never registered one.
With more than one server in the process the one that asked for the most wins: the largest value of all of them, and no deadline at all once one of them registered a zero or negative value. A smaller one would cut the drain of the server that asked for more.
One limit of that rule: a value is never taken back, so a server that has stopped still counts. One that asked for no deadline lifts it for the rest of the process, whatever the servers started after it ask for.
func Wait ¶ added in v14.0.1
func Wait()
Wait blocks while the closers of an interrupt signal are running, so a caller that is about to let the process end gives them the chance to finish. It returns at once when no signal has been received.
The process exits as soon as they are done, so a Wait that blocked returns at the moment the process is going away. When a closer returned an error it does not return at all: the process exits with status 1 while it is still blocked.
Types ¶
This section is empty.