1package lifecycle 2 3import ( 4 "os" 5 "time" 6) 7 8// An Option is used to configure the lifecycle manager 9type Option func(*manager) 10 11// WithTimeout sets an upper limit for how much time Handle will wait to return. 12// After the Go funcs finish, if WhenDone was used, or after a signal is 13// received if WhenSignaled was used, this timer starts. From that point, Handle 14// will return if any Go or Defer function takes longer than this value. 15func WithTimeout(val time.Duration) Option { 16 return func(o *manager) { 17 o.timeout = val 18 } 19} 20 21// WithSignals causes Handle to wait for Go funcs to finish, if WhenDone was 22// used or until a signal is received. The signals it will wait for can be 23// defined with WithSigs or will default to syscall.SIGINT and syscall.SIGTERM 24func WithSignals(val ...os.Signal) Option { 25 return func(o *manager) { 26 o.sigs = val 27 } 28} 29