kill process... may be infinite if no end

This commit is contained in:
mr 2025-06-18 11:07:25 +02:00
parent cb23289097
commit 81167f7b86

View File

@ -130,9 +130,11 @@ func (p *PrometheusService) Call(book *booking.Booking) (*booking.Booking, map[s
var LockKill = &sync.Mutex{} var LockKill = &sync.Mutex{}
func (p *PrometheusService) Stream(bookingID string, end *time.Time, interval time.Duration, flusher *http.Flusher, encoder *json.Encoder) { 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) f := func(e *time.Time) bool {
if end != nil { if end == nil {
e = (*end).UTC() return true
}
return time.Now().Before(*e)
} }
max := 100 max := 100
bookIDS := []string{} bookIDS := []string{}
@ -142,7 +144,8 @@ func (p *PrometheusService) Stream(bookingID string, end *time.Time, interval ti
if book.Err != "" { if book.Err != "" {
fmt.Errorf("stop because of empty : %s", 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) { if slices.Contains(Kill, book.Data.(*booking.Booking).ExecutionsID) {
newKill := []string{} newKill := []string{}
for _, k := range Kill { for _, k := range Kill {