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 {