@@ -18,8 +18,9 @@ import (
18
18
19
19
var (
20
20
serialized map [string ]Leaky
21
- BucketPourCache map [string ][]types.Event
21
+ BucketPourCache map [string ][]types.Event = make ( map [ string ][]types. Event )
22
22
BucketPourTrack bool
23
+ bucketPourMu sync.Mutex
23
24
)
24
25
25
26
/*
@@ -158,11 +159,11 @@ func PourItemToBucket(bucket *Leaky, holder BucketFactory, buckets *Buckets, par
158
159
case bucket .In <- parsed :
159
160
//holder.logger.Tracef("Successfully sent !")
160
161
if BucketPourTrack {
161
- if _ , ok := BucketPourCache [ bucket . Name ]; ! ok {
162
- BucketPourCache [ bucket . Name ] = make ([]types. Event , 0 )
163
- }
164
- evt := deepcopy . Copy ( * parsed )
165
- BucketPourCache [ bucket . Name ] = append ( BucketPourCache [ bucket . Name ], evt .(types. Event ) )
162
+ evt := deepcopy . Copy ( * parsed ).(types. Event )
163
+
164
+ bucketPourMu . Lock ()
165
+ BucketPourCache [ bucket . Name ] = append ( BucketPourCache [ bucket . Name ], evt )
166
+ bucketPourMu . Unlock ( )
166
167
}
167
168
sent = true
168
169
continue
@@ -220,14 +221,11 @@ func PourItemToHolders(parsed types.Event, holders []BucketFactory, buckets *Buc
220
221
var ok , condition , poured bool
221
222
222
223
if BucketPourTrack {
223
- if BucketPourCache == nil {
224
- BucketPourCache = make (map [string ][]types.Event )
225
- }
226
- if _ , ok = BucketPourCache ["OK" ]; ! ok {
227
- BucketPourCache ["OK" ] = make ([]types.Event , 0 )
228
- }
229
- evt := deepcopy .Copy (parsed )
230
- BucketPourCache ["OK" ] = append (BucketPourCache ["OK" ], evt .(types.Event ))
224
+ evt := deepcopy .Copy (parsed ).(types.Event )
225
+
226
+ bucketPourMu .Lock ()
227
+ BucketPourCache ["OK" ] = append (BucketPourCache ["OK" ], evt )
228
+ bucketPourMu .Unlock ()
231
229
}
232
230
//find the relevant holders (scenarios)
233
231
for idx := range holders {
0 commit comments