Add metric type to metric struct.

This commit is contained in:
Stanislav Nikitin 2020-12-23 13:45:33 +05:00
parent 7e90814fde
commit c34babeaf8
Signed by: pztrn
GPG Key ID: 1E944A0F0568B550
3 changed files with 6 additions and 3 deletions

View File

@ -48,7 +48,7 @@ func (a *Application) parse(body string) map[string]models.Metric {
}
}
metric := models.NewMetric(name, "", params)
metric := models.NewMetric(name, "", "", params)
metric.SetValue(value)
data[name] = metric

View File

@ -8,15 +8,18 @@ type Metric struct {
Description string
// Additional parameters, data inside "{}".
Params []string
// Type is a metric type.
Type string
// Metric value.
Value string
}
// NewMetric creates new structure for storing single metric data.
func NewMetric(name, description string, params []string) Metric {
func NewMetric(name, mType, description string, params []string) Metric {
m := Metric{
Name: name,
Description: description,
Type: mType,
Params: params,
}

View File

@ -40,7 +40,7 @@ func (s *Storage) Get(key string) (models.Metric, error) {
data, found := s.data[key]
if !found {
return models.NewMetric("", "", nil), ErrMetricNotFound
return models.NewMetric("", "", "", nil), ErrMetricNotFound
}
return data, nil