Documentation ¶
Index ¶
- Constants
- Variables
- func Decode(r io.ReadCloser, v interface{}) error
- func Encode(w http.ResponseWriter, v interface{}, status int)
- func FileSize(recID string, opener string) (int64, string)
- func GetConf(c interface{}, path string) error
- func Init(cfgPath string, name string)
- func InitMetrics()
- func LoadConfig(testConfig bool)
- func NewJSONError(c int, m string) error
- func SetupLocalizer()
- func Trace(s string) (string, time.Time)
- func Un(s string, startTime time.Time)
- func Write(w http.ResponseWriter, jse error)
- type CacheConfig
- type DatabaseConfig
- type DbHTTPErr
- type EmailConfig
- type ErrorInfo
- type JSONError
- type ServerConfig
- type Set
Constants ¶
const SystemAccount = "bwXbluwC"
SystemAccount stores bluwhaze's internal system account ID
Variables ¶
var ( // GenerationDuration measures the runtime for playlist generation GenerationDuration = prometheus.NewHistogram(prometheus.HistogramOpts{ Name: "generate_playlist_request_duration_seconds", Help: "Histogram for the runtime of generating the playlist.", Buckets: []float64{0.1, 0.2, 0.4, 0.6, 1, 2, 5, 10}, }) // FeedbackRequest measures the feedback request latencies FeedbackRequest = prometheus.NewHistogram(prometheus.HistogramOpts{ Name: "fb_req", Help: "Histogram for the runtime of requesting feedback.", Buckets: []float64{0.1, 0.2, 0.4, 0.6, 1, 2, 5, 10}, }) // FeedbackInstrumentPreference is a counter for feedback instrument preferences FeedbackInstrumentPreference = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "fb_inst_pref", Help: "A counter vec for feedback requested instrument preferences.", }, []string{"inst"}, ) // FeedbackRequestSize is a counter feedback files sent FeedbackRequestSize = prometheus.NewCounter( prometheus.CounterOpts{ Name: "fb_size", Help: "A counter for feedback files sent.", }, ) // FeedbackGenrePreference is a counter for feedback genre preferences FeedbackGenrePreference = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "fb_genr_pref", Help: "A counter vec for feedback requested genre preferences.", }, []string{"genr"}, ) // RequestGauge represents a gauge of reqeusts RequestGauge = prometheus.NewGauge(prometheus.GaugeOpts{ Name: "in_flight_requests", Help: "A gauge of requests currently being served by the wrapped handler.", }) // RequestCounter is a counter for wrapped requests RequestCounter = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "api_requests_total", Help: "A counter for requests to the wrapped handler.", }, []string{"code", "method"}, ) // RequestDuration is a histogram of latencies RequestDuration = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Name: "request_duration_seconds", Help: "A histogram of latencies for requests.", Buckets: []float64{0.05, 0.1, 0.2, 0.25, .5, 1, 2.5, 5, 10}, }, []string{"method"}, ) // ResponseSize is a histogram of response sizes ResponseSize = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Name: "response_size_bytes", Help: "A histogram of response sizes for requests.", Buckets: []float64{200, 500, 1000, 25000, 50000, 1000000, 5000000}, }, []string{}, ) )
TODO: not all of these need to be globals
var ConfigFile string
ConfigFile points to the config file
var Data *config
Data contains the global configuration
Db contains the global database connection
var DebugMode bool
DebugMode sets the database debug mode
var Exists = struct{}{}
Exists allows you to mark the existence inside the set
Localizer is an i18n localizer
Log provides global logging
var LogFile string
LogFile points to the log file
var Token tokenSecrets
Token contains the JWT secrets
Functions ¶
func Decode ¶
func Decode(r io.ReadCloser, v interface{}) error
Decode tries to decode the interface as json
func Encode ¶
func Encode(w http.ResponseWriter, v interface{}, status int)
Encode writes the encoded value
func FileSize ¶
FileSize returns a filesize for a feedback recording
func GetConf ¶
GetConf parses the specified yaml config file with provided struct
func LoadConfig ¶
func LoadConfig(testConfig bool)
LoadConfig loads the secrets from the config file
func Write ¶
func Write(w http.ResponseWriter, jse error)
Write writes the error to the http response
Types ¶
type CacheConfig ¶
CacheConfig contains the cache server settings
type DatabaseConfig ¶
type DatabaseConfig struct { Host string `yaml:"host"` Port int `yaml:"port"` User string `yaml:"user"` DbName string `yaml:"dbname"` Password string `yaml:"password"` }
DatabaseConfig contains the database connection information
type DbHTTPErr ¶
DbHTTPErr contains a mapping of database errors with HTTP statuses
type EmailConfig ¶
type EmailConfig struct { Host string `yaml:"host"` Port int `yaml:"port"` User string `yaml:"user"` Password string `yaml:"password"` }
EmailConfig contains the email connection information
type ErrorInfo ¶
type ErrorInfo struct { Code string `json:"code"` HTTPStatus int `json:"-"` Message string `json:"message"` }
ErrorInfo contains error information