Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- func (c Config) DebugLog() log.LogLocation
- func (c Config) ErrorLog() log.LogLocation
- func (c Config) EventLog() log.LogLocation
- func (c Config) InfoLog() log.LogLocation
- func (c *Config) MarshalJSON() ([]byte, error)
- func (c *Config) UnmarshalJSON(data []byte) error
- func (c Config) WarningLog() log.LogLocation
- type LogLocation
- type PollingProtocol
- type StaticAppData
Constants ¶
const ( // LogLocationStdout indicates the stdout IO stream LogLocationStdout = "stdout" // LogLocationStderr indicates the stderr IO stream LogLocationStderr = "stderr" // LogLocationNull indicates the null IO stream (/dev/null) LogLocationNull = "null" //StaticFileDir is the directory that contains static html and js files. StaticFileDir = "/opt/traffic_monitor/static/" //CrConfigBackupFile is the default file name to store the last crconfig CRConfigBackupFile = "/opt/traffic_monitor/crconfig.backup" //TmConfigBackupFile is the default file name to store the last tmconfig TMConfigBackupFile = "/opt/traffic_monitor/tmconfig.backup" //HTTPPollingFormat is the default accept encoding for stats from caches HTTPPollingFormat = "text/json" )
const ( IPv4Only = PollingProtocol("ipv4only") IPv6Only = PollingProtocol("ipv6only") Both = PollingProtocol("both") InvalidPollingProtocol = PollingProtocol("invalid_polling_protocol") )
Variables ¶
var DefaultConfig = Config{ CacheHealthPollingInterval: 6 * time.Second, CacheStatPollingInterval: 6 * time.Second, MonitorConfigPollingInterval: 5 * time.Second, HTTPTimeout: 2 * time.Second, PeerPollingInterval: 5 * time.Second, PeerOptimistic: true, PeerOptimisticQuorumMin: 0, MaxEvents: 200, MaxStatHistory: 5, MaxHealthHistory: 5, HealthFlushInterval: 200 * time.Millisecond, StatFlushInterval: 200 * time.Millisecond, StatBufferInterval: 0, LogLocationError: LogLocationStderr, LogLocationWarning: LogLocationStdout, LogLocationInfo: LogLocationNull, LogLocationDebug: LogLocationNull, LogLocationEvent: LogLocationStdout, ServeReadTimeout: 10 * time.Second, ServeWriteTimeout: 10 * time.Second, HealthToStatRatio: 4, StaticFileDir: StaticFileDir, CRConfigHistoryCount: 20000, TrafficOpsMinRetryInterval: 100 * time.Millisecond, TrafficOpsMaxRetryInterval: 60000 * time.Millisecond, CRConfigBackupFile: CRConfigBackupFile, TMConfigBackupFile: TMConfigBackupFile, TrafficOpsDiskRetryMax: 2, CachePollingProtocol: Both, PeerPollingProtocol: Both, HTTPPollingFormat: HTTPPollingFormat, }
DefaultConfig is the default configuration for the application, if no configuration file is given, or if a given config setting doesn't exist in the config file.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { CacheHealthPollingInterval time.Duration `json:"-"` CacheStatPollingInterval time.Duration `json:"-"` MonitorConfigPollingInterval time.Duration `json:"-"` HTTPTimeout time.Duration `json:"-"` PeerPollingInterval time.Duration `json:"-"` PeerOptimistic bool `json:"peer_optimistic"` PeerOptimisticQuorumMin int `json:"peer_optimistic_quorum_min"` MaxEvents uint64 `json:"max_events"` MaxStatHistory uint64 `json:"max_stat_history"` MaxHealthHistory uint64 `json:"max_health_history"` HealthFlushInterval time.Duration `json:"-"` StatFlushInterval time.Duration `json:"-"` StatBufferInterval time.Duration `json:"-"` LogLocationError string `json:"log_location_error"` LogLocationWarning string `json:"log_location_warning"` LogLocationInfo string `json:"log_location_info"` LogLocationDebug string `json:"log_location_debug"` LogLocationEvent string `json:"log_location_event"` ServeReadTimeout time.Duration `json:"-"` ServeWriteTimeout time.Duration `json:"-"` HealthToStatRatio uint64 `json:"health_to_stat_ratio"` StaticFileDir string `json:"static_file_dir"` CRConfigHistoryCount uint64 `json:"crconfig_history_count"` TrafficOpsMinRetryInterval time.Duration `json:"-"` TrafficOpsMaxRetryInterval time.Duration `json:"-"` CRConfigBackupFile string `json:"crconfig_backup_file"` TMConfigBackupFile string `json:"tmconfig_backup_file"` TrafficOpsDiskRetryMax uint64 `json:"-"` CachePollingProtocol PollingProtocol `json:"cache_polling_protocol"` PeerPollingProtocol PollingProtocol `json:"peer_polling_protocol"` HTTPPollingFormat string `json:"http_polling_format"` }
Config is the configuration for the application. It includes myriad data, such as polling intervals and log locations.
func Load ¶
Load loads the given config file. If an empty string is passed, the default config is returned.
func (*Config) MarshalJSON ¶
MarshalJSON marshals custom millisecond durations. Aliasing inspired by http://choly.ca/post/go-json-marshalling/
func (*Config) UnmarshalJSON ¶
UnmarshalJSON populates this config object from given JSON bytes.
func (Config) WarningLog ¶
func (c Config) WarningLog() log.LogLocation
type LogLocation ¶
type LogLocation string
LogLocation is a location to log to. This may be stdout, stderr, null (/dev/null), or a valid file path.
type PollingProtocol ¶
type PollingProtocol string
PollingProtocol is a string value indicating whether to use IPv4, IPv6, or both.
func PollingProtocolFromString ¶
func PollingProtocolFromString(s string) PollingProtocol
PollingProtocolFromString returns a PollingProtocol based on the string input.
func (PollingProtocol) String ¶
func (t PollingProtocol) String() string
String returns a string representation of this PollingProtocol.
func (*PollingProtocol) UnmarshalJSON ¶
func (t *PollingProtocol) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaller interface
type StaticAppData ¶
type StaticAppData struct { StartTime time.Time GitRevision string FreeMemoryMB uint64 Version string WorkingDir string Name string BuildTimestamp string Hostname string UserAgent string }
StaticAppData encapsulates data about the app available at startup
func GetStaticAppData ¶
func GetStaticAppData(version, gitRevision, buildTimestamp string) (StaticAppData, error)
getStaticAppData returns app data available at start time. This should be called immediately, as it includes calculating when the app was started.