Refactor environment handling logic to separate a server from the environment handler itself
This change makes the environment handling logic execute independent of the server itself and should make it much easier for people to contribute changes and additional environment handlers down the road without polluting the server object even more. There is still a lot of work to do on this front to make things easier to work with, and there are some questionable design decisions at play I'm sure. Welcome to additional modifications and cleanup to make this code easier to reason about and work with.
This commit is contained in:
@@ -55,24 +55,7 @@ type Configuration struct {
|
||||
|
||||
// Defines internal throttling configurations for server processes to prevent
|
||||
// someone from running an endless loop that spams data to logs.
|
||||
Throttles struct {
|
||||
// The number of data overage warnings (inclusive) that can accumulate
|
||||
// before a process is terminated.
|
||||
KillAtCount int `default:"5" yaml:"kill_at_count"`
|
||||
|
||||
// The number of seconds that must elapse before the internal counter
|
||||
// begins decrementing warnings assigned to a process that is outputting
|
||||
// too much data.
|
||||
DecaySeconds int `default:"10" json:"decay" yaml:"decay"`
|
||||
|
||||
// The total number of bytes allowed to be output by a server process
|
||||
// per interval.
|
||||
BytesPerInterval int `default:"4096" json:"bytes" yaml:"bytes"`
|
||||
|
||||
// The amount of time that should lapse between data output throttle
|
||||
// checks. This should be defined in milliseconds.
|
||||
CheckInterval int `default:"100" yaml:"check_interval"`
|
||||
}
|
||||
Throttles ConsoleThrottles
|
||||
|
||||
// The location where the panel is running that this daemon should connect to
|
||||
// to collect data and send events.
|
||||
|
||||
23
config/config_throttles.go
Normal file
23
config/config_throttles.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package config
|
||||
|
||||
type ConsoleThrottles struct {
|
||||
// Wether or not the throttler is enabled for this instance.
|
||||
Enabled bool `json:"enabled" yaml:"enabled" default:"true"`
|
||||
|
||||
// The total number of throttle activations that must accumulate before a server is
|
||||
// forcibly stopped for violating these limits.
|
||||
KillAtCount uint64 `json:"kill_at_count" yaml:"kill_at_count" default:"5"`
|
||||
|
||||
// The amount of time in milliseconds that a server process must go through without
|
||||
// triggering an output warning before the throttle activation count begins decreasing.
|
||||
// This time is measured in milliseconds.
|
||||
Decay uint64 `json:"decay" yaml:"decay" default:"10000"`
|
||||
|
||||
// The total number of lines that can be output in a given CheckInterval period before
|
||||
// a warning is triggered and counted against the server.
|
||||
Lines uint64 `json:"lines" yaml:"lines" default:"1000"`
|
||||
|
||||
// The amount of time that must pass between intervals before the count is reset. This
|
||||
// value is in milliseconds.
|
||||
CheckInterval uint64 `json:"check_interval" yaml:"check_interval" default:"100"`
|
||||
}
|
||||
Reference in New Issue
Block a user