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,
|
// 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 {
|
switch rInfo.RequestType {
|
||||||
// ToDo: move to constants.
|
// ToDo: move to constants.
|
||||||
case "apps_list":
|
case "apps_list":
|
||||||
|
@ -22,6 +22,8 @@ type HTTPServer struct {
|
|||||||
server *http.Server
|
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{}) {
|
func NewHTTPServer(ctx context.Context, cfg *configuration.Config, logger *logger.Logger) (*HTTPServer, chan struct{}) {
|
||||||
h := &HTTPServer{
|
h := &HTTPServer{
|
||||||
config: cfg,
|
config: cfg,
|
||||||
|
@ -2,5 +2,6 @@ package logger
|
|||||||
|
|
||||||
// Config represents logging configuration.
|
// Config represents logging configuration.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
// Debug is a flag that indicates that we should print out debug output.
|
||||||
Debug bool `yaml:"debug"`
|
Debug bool `yaml:"debug"`
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,14 @@ package models
|
|||||||
|
|
||||||
// RequestInfo is a parsed request information to throw into application's handler.
|
// RequestInfo is a parsed request information to throw into application's handler.
|
||||||
type RequestInfo struct {
|
type RequestInfo struct {
|
||||||
|
// Application is a name of application. We should ask it's handler for metrics.
|
||||||
Application string
|
Application string
|
||||||
Metric 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
|
RequestType string
|
||||||
APIVersion int
|
// APIVersion is a version of API requested.
|
||||||
|
APIVersion int
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,16 @@ import (
|
|||||||
"go.dev.pztrn.name/metricator/internal/models"
|
"go.dev.pztrn.name/metricator/internal/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ErrMetricNotFound appears if requested metric wasn't found in storage.
|
||||||
var ErrMetricNotFound = errors.New("metric not found")
|
var ErrMetricNotFound = errors.New("metric not found")
|
||||||
|
|
||||||
// Storage is an in-memory storage.
|
// Storage is an in-memory storage.
|
||||||
type Storage struct {
|
type Storage struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
doneChan chan struct{}
|
doneChan chan struct{}
|
||||||
logger *logger.Logger
|
logger *logger.Logger
|
||||||
name string
|
|
||||||
|
|
||||||
data map[string]models.Metric
|
data map[string]models.Metric
|
||||||
|
name string
|
||||||
dataMutex sync.RWMutex
|
dataMutex sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user