try this
This commit is contained in:
parent
10ed2b8680
commit
8f1ca97a88
|
@ -70,6 +70,7 @@ type Leaky struct {
|
||||||
wgPour *sync.WaitGroup
|
wgPour *sync.WaitGroup
|
||||||
wgDumpState *sync.WaitGroup
|
wgDumpState *sync.WaitGroup
|
||||||
mutex *sync.Mutex //used only for TIMEMACHINE mode to allow garbage collection without races
|
mutex *sync.Mutex //used only for TIMEMACHINE mode to allow garbage collection without races
|
||||||
|
orderEvent bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var BucketsPour = prometheus.NewCounterVec(
|
var BucketsPour = prometheus.NewCounterVec(
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/antonmedv/expr"
|
"github.com/antonmedv/expr"
|
||||||
|
@ -279,6 +280,8 @@ func LoadOrStoreBucketFromHolder(partitionKey string, buckets *Buckets, holder B
|
||||||
return biface.(*Leaky), nil
|
return biface.(*Leaky), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var orderEvent map[string]*sync.WaitGroup
|
||||||
|
|
||||||
func PourItemToHolders(parsed types.Event, holders []BucketFactory, buckets *Buckets) (bool, error) {
|
func PourItemToHolders(parsed types.Event, holders []BucketFactory, buckets *Buckets) (bool, error) {
|
||||||
var (
|
var (
|
||||||
ok, condition, poured bool
|
ok, condition, poured bool
|
||||||
|
@ -344,7 +347,21 @@ func PourItemToHolders(parsed types.Event, holders []BucketFactory, buckets *Buc
|
||||||
return false, fmt.Errorf("failed to load or store bucket: %w", err)
|
return false, fmt.Errorf("failed to load or store bucket: %w", err)
|
||||||
}
|
}
|
||||||
//finally, pour the even into the bucket
|
//finally, pour the even into the bucket
|
||||||
|
|
||||||
|
if bucket.orderEvent {
|
||||||
|
if orderEvent == nil {
|
||||||
|
orderEvent = make(map[string]*sync.WaitGroup)
|
||||||
|
}
|
||||||
|
orderEvent[buckey] = &sync.WaitGroup{}
|
||||||
|
orderEvent[buckey].Add(1)
|
||||||
|
}
|
||||||
|
|
||||||
ok, err := PourItemToBucket(bucket, holders[idx], buckets, &parsed)
|
ok, err := PourItemToBucket(bucket, holders[idx], buckets, &parsed)
|
||||||
|
|
||||||
|
if bucket.orderEvent {
|
||||||
|
orderEvent[buckey].Wait()
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("failed to pour bucket: %w", err)
|
return false, fmt.Errorf("failed to pour bucket: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue