diff --git a/cmd/main.go b/cmd/main.go index 3e0bd27..0963fd9 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -54,5 +54,8 @@ func httpHandler(res http.ResponseWriter, req *http.Request) { } fmt.Fprintf(res, metric.Format()) + if liveMetrics.isLastMetric() { + break + } } } diff --git a/cmd/queue.go b/cmd/queue.go index af9ef44..9b0c195 100644 --- a/cmd/queue.go +++ b/cmd/queue.go @@ -29,3 +29,7 @@ func (q *Queue[T]) Pop() (*T, bool) { return &val, true } + +func (q *Queue[T]) isLastMetric() bool { + return q.Size == 1 +}