Linting and comments.
This commit is contained in:
parent
08d5f36c36
commit
115e5d5051
@ -137,7 +137,7 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Process request type. Here we process only known requests types,
|
||||
// by default request should go to specific application's handler.
|
||||
// all other requests will produce HTTP 400 error.
|
||||
switch rInfo.RequestType {
|
||||
// ToDo: move to constants.
|
||||
case "apps_list":
|
||||
|
@ -22,6 +22,8 @@ type HTTPServer struct {
|
||||
server *http.Server
|
||||
}
|
||||
|
||||
// NewHTTPServer creates HTTP server and executes preliminary initialization
|
||||
// (HTTP server structure initialized but it doesn't start).
|
||||
func NewHTTPServer(ctx context.Context, cfg *configuration.Config, logger *logger.Logger) (*HTTPServer, chan struct{}) {
|
||||
h := &HTTPServer{
|
||||
config: cfg,
|
||||
|
@ -2,5 +2,6 @@ package logger
|
||||
|
||||
// Config represents logging configuration.
|
||||
type Config struct {
|
||||
// Debug is a flag that indicates that we should print out debug output.
|
||||
Debug bool `yaml:"debug"`
|
||||
}
|
||||
|
@ -2,8 +2,14 @@ package models
|
||||
|
||||
// RequestInfo is a parsed request information to throw into application's handler.
|
||||
type RequestInfo struct {
|
||||
// Application is a name of application. We should ask it's handler for metrics.
|
||||
Application string
|
||||
// Metric is a metric name with parameters (e.g. requests{path='/',code=200} will
|
||||
// be "requests/path:\//code:200").
|
||||
Metric string
|
||||
// Request type is a type of request. Currently known: "apps_list", "info", and "metrics".
|
||||
// All other request types will produce HTTP 400 error.
|
||||
RequestType string
|
||||
// APIVersion is a version of API requested.
|
||||
APIVersion int
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"go.dev.pztrn.name/metricator/internal/models"
|
||||
)
|
||||
|
||||
// ErrMetricNotFound appears if requested metric wasn't found in storage.
|
||||
var ErrMetricNotFound = errors.New("metric not found")
|
||||
|
||||
// Storage is an in-memory storage.
|
||||
@ -16,9 +17,8 @@ type Storage struct {
|
||||
ctx context.Context
|
||||
doneChan chan struct{}
|
||||
logger *logger.Logger
|
||||
name string
|
||||
|
||||
data map[string]models.Metric
|
||||
name string
|
||||
dataMutex sync.RWMutex
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user