From 81167f7b8663572391cd854209ba3746c961289d Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 18 Jun 2025 11:07:25 +0200 Subject: [PATCH] kill process... may be infinite if no end --- infrastructure/prometheus.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/infrastructure/prometheus.go b/infrastructure/prometheus.go index 77d282a..90e98c4 100644 --- a/infrastructure/prometheus.go +++ b/infrastructure/prometheus.go @@ -130,9 +130,11 @@ func (p *PrometheusService) Call(book *booking.Booking) (*booking.Booking, map[s var LockKill = &sync.Mutex{} func (p *PrometheusService) Stream(bookingID string, end *time.Time, interval time.Duration, flusher *http.Flusher, encoder *json.Encoder) { - e := time.Now().UTC().Add(time.Hour * 1) - if end != nil { - e = (*end).UTC() + f := func(e *time.Time) bool { + if end == nil { + return true + } + return time.Now().Before(*e) } max := 100 bookIDS := []string{} @@ -142,7 +144,8 @@ func (p *PrometheusService) Stream(bookingID string, end *time.Time, interval ti if book.Err != "" { fmt.Errorf("stop because of empty : %s", book.Err) } - for time.Now().Before(e) { + + for f(end) { if slices.Contains(Kill, book.Data.(*booking.Booking).ExecutionsID) { newKill := []string{} for _, k := range Kill {