Documentation
¶
Index ¶
- func GetBoolEnv(key string, fallback bool) bool
- func GetDurationEnv(key string, fallback time.Duration) time.Duration
- func GetStringEnv(key, fallback string) string
- func RegisterInterruptHandler(cancelApp context.CancelFunc, eventFn func())
- func RegisterSignalHandler(cancel context.CancelFunc, sigs ...os.Signal)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBoolEnv ¶
GetBoolEnv parses a boolean environment variable by the given key, if env is empty, returns the given fallback value
func GetDurationEnv ¶
GetDurationEnv parses a duration environment variable by the given key, if env is empty, returns the given fallback value
func GetStringEnv ¶
GetStringEnv returns an environment variable by the given key, if env is empty, returns the given fallback value
func RegisterInterruptHandler ¶
func RegisterInterruptHandler(cancelApp context.CancelFunc, eventFn func())
RegisterInterruptHandler registers a handler of interrupt signals from the OS. When signal os.Interrupt is coming, it informs the user about it and calls func `cancelApp`.
func RegisterSignalHandler ¶
func RegisterSignalHandler(cancel context.CancelFunc, sigs ...os.Signal)
RegisterSignalHandler registers a handler of signals from the OS. Before using it you have to ensure a exit from each loop when <-ctx.Done() is releasing Example:
func HelloWorld(ctx context.Context) {
for {
select {
case <-ctx.Done():
return
default:
}
.....
}
}
Types ¶
This section is empty.