The very basic metricator-client and package.

Package can be used in external things if needed.
This commit is contained in:
2020-12-24 23:06:13 +05:00
parent f1418a7a31
commit 614526b16d
10 changed files with 305 additions and 18 deletions

View File

@@ -3,12 +3,12 @@ package application
import (
"strings"
"go.dev.pztrn.name/metricator/internal/models"
"go.dev.pztrn.name/metricator/pkg/schema"
)
// Parses passed body and returns a map suitable for pushing into storage.
func (a *Application) parse(body string) map[string]models.Metric {
data := make(map[string]models.Metric)
func (a *Application) parse(body string) map[string]schema.Metric {
data := make(map[string]schema.Metric)
// ToDo: switch to bytes buffer and maybe do not read body in caller?
splittedBody := strings.Split(body, "\n")
@@ -35,7 +35,7 @@ func (a *Application) parse(body string) map[string]models.Metric {
if !found {
a.logger.Debugln("Metric wasn't yet created, creating new structure")
metric = models.NewMetric(name, "", "", nil)
metric = schema.NewMetric(name, "", "", nil)
}
a.logger.Debugf("Got metric to use: %+v\n", metric)