github.com/blend/go-sdk@v1.20220411.3/graceful/shutdown_options.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package graceful
     9  
    10  import (
    11  	"os"
    12  )
    13  
    14  // OptDefaultShutdownSignal returns an option that sets the shutdown signal to the defaults.
    15  func OptDefaultShutdownSignal() ShutdownOption {
    16  	return func(so *ShutdownOptions) { so.ShutdownSignal = Notify(DefaultShutdownSignals...) }
    17  }
    18  
    19  // OptShutdownSignal sets the shutdown signal.
    20  func OptShutdownSignal(signal chan os.Signal) ShutdownOption {
    21  	return func(so *ShutdownOptions) { so.ShutdownSignal = signal }
    22  }
    23  
    24  // ShutdownOption is a mutator for shutdown options.
    25  type ShutdownOption func(*ShutdownOptions)
    26  
    27  // ShutdownOptions are the options for graceful shutdown.
    28  type ShutdownOptions struct {
    29  	ShutdownSignal chan os.Signal
    30  }