Значения по-умолчанию
ADDRESS=localhost:8080
STORE_INTERVAL=300
FILE_STORAGE_PATH=/tmp/metrics-db.json
RESTORE=true
DATABASE_DSN=postgres://postgres:password@172.22.0.2:5432/yp_metrics
KEY=key
CRYPTO_KEY=/tmp/go-musthave-metrics/private.pem
TRUSTED_SUBNET=192.168.0.0/24
GRPC_ADDRESS=localhost:3200
docker-compose up -d
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' yp-musthave-metrics-postgres
ADDRESS=localhost:8080
REPORT_INTERVAL=10
POLL_INTERVAL=2
KEY="abc"
RATE_LIMIT=4
CRYPTO_KEY=/tmp/go-musthave-metrics/public.key
X_REAL_IP=192.168.1.1
USE_GRPC=true
POST localhost:8080/update/
Content-Type: application/json
{
"id": "PollCount",
"type": "counter",
"delta": 1
}
POST localhost:8080/value/
Content-Type: application/json
{
"id": "PollCount",
"type": "counter",
}
POST localhost:8080/updates/
Content-Type: application/json
[
{
"id": "PollCount",
"type": "counter",
"delta": 1
},
{
"id": "GaugeABC",
"type": "gauge",
"value": 19.17
}
]
Сохраните профиль потребления памяти.
Запустим 2 сервиса и дадим им чуток поработать.
mkdir -p ./profiles/server
mkdir -p ./profiles/client
curl http://localhost:8080/debug/pprof/allocs > ./profiles/server/allocs.base.pprof
# go tool pprof -http=":9090" -seconds=30 http://localhost:8080/debug/pprof/allocs
go tool pprof -http=":9090" -seconds=30 ./profiles/server/allocs.base.pprof
Тут видно что больше всего памяти потребляет compress/flate.NewWriter.
mkdir -p ./profiles/client
curl http://localhost:8081/debug/pprof/allocs > ./profiles/client/allocs.base.pprof
# go tool pprof -http=":9090" -seconds=30 http://localhost:8081/debug/pprof/allocs
go tool pprof -http=":9090" -seconds=30 ./profiles/client/allocs.base.pprof
Тут видно что больше всего памяти потребляет compress/flate.NewWriter.
swag init --dir=./cmd/agent --output ./swagger/agent
swag init --dir=./cmd/server --output ./swagger/server
Проверить код своим родным линтером
go build -o staticlint ./cmd/staticlint/
./staticlint ./internal/server/...
Сгенерировать ключи командой
go build -o keygen ./cmd/keygen
./keygen -path .
protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative proto/message.proto