github.com/anycable/anycable-go@v1.5.1/node/config.go (about)

     1  package node
     2  
     3  const (
     4  	DISCONNECT_MODE_ALWAYS = "always"
     5  	DISCONNECT_MODE_AUTO   = "auto"
     6  	DISCONNECT_MODE_NEVER  = "never"
     7  )
     8  
     9  var DISCONNECT_MODES = []string{DISCONNECT_MODE_ALWAYS, DISCONNECT_MODE_AUTO, DISCONNECT_MODE_NEVER}
    10  
    11  // Config contains general application/node settings
    12  type Config struct {
    13  	// Define when to invoke Disconnect callback
    14  	DisconnectMode string
    15  	// The number of goroutines to use for disconnect calls on shutdown
    16  	ShutdownDisconnectPoolSize int
    17  	// How often server should send Action Cable ping messages (seconds)
    18  	PingInterval int
    19  	// How ofter to refresh node stats (seconds)
    20  	StatsRefreshInterval int
    21  	// The max size of the Go routines pool for hub
    22  	HubGopoolSize int
    23  	// How should ping message timestamp be formatted? ('s' => seconds, 'ms' => milli seconds, 'ns' => nano seconds)
    24  	PingTimestampPrecision string
    25  	// For how long to wait for pong message before disconnecting (seconds)
    26  	PongTimeout int
    27  	// For how long to wait for disconnect callbacks to be processed before exiting (seconds)
    28  	ShutdownTimeout int
    29  }
    30  
    31  // NewConfig builds a new config
    32  func NewConfig() Config {
    33  	return Config{
    34  		PingInterval:               3,
    35  		StatsRefreshInterval:       5,
    36  		HubGopoolSize:              16,
    37  		ShutdownDisconnectPoolSize: 16,
    38  		PingTimestampPrecision:     "s",
    39  		DisconnectMode:             DISCONNECT_MODE_AUTO,
    40  		ShutdownTimeout:            30,
    41  	}
    42  }