Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlockedUntilTerminate ¶
func BlockedUntilTerminate()
BlockedUntilTerminate blocks the current goroutine until a termination signal is received and all exit functions have completed. This function should be called to ensure the program does not exit immediately and waits for a proper shutdown sequence.
func Exit ¶ added in v1.2.17
func Exit()
Exit sends a termination signal to the signal channel, initiating the shutdown process.
func PrintlnUntilDone ¶ added in v1.2.17
PrintlnUntilDone prints a message at regular intervals until the provided done channel is closed.
Parameters:
message (string): The message to be printed periodically.
interval (time.Duration): The interval at which the message is printed.
done (chan struct{}): A channel that, when closed, stops the printing of the message.
func RegisterExitEvent ¶ added in v1.2.17
func RegisterExitEvent(fn EventHandler, eventName string)
RegisterExitEvent registers an event handler for a specific exit event. The event handler is stored in the eventList map with the provided event name as the key. If the event handler function is not nil, it also prints details about the registration, including the event name, the location of the event handler function, and the location where the registration occurred.
Parameters:
fn (EventHandler): The event handler function to be registered. It should
handle an os.Signal parameter.
eventName (string): The name of the event for which the handler is being
registered. This name is used as the key in the eventList map.
Types ¶
type EventHandler ¶
EventHandler is a function type that takes an os.Signal as its parameter. This function is intended to handle the signal received during the program's exit process.