Skip to content

Commit 991682f

Browse files
authored
pkg/leakybucket: remove Simulated field from Leaky, keep it in config (#4285)
1 parent 7610a5d commit 991682f

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

pkg/leakybucket/bucket.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ type Leaky struct {
4949
doneOnce sync.Once // use to prevent double close
5050
Suicide chan bool `json:"-"`
5151
Reprocess bool
52-
Simulated bool
5352
Uuid string
5453
First_ts time.Time
5554
Last_ts time.Time
@@ -117,7 +116,6 @@ func NewLeakyFromFactory(f *BucketFactory) *Leaky {
117116
scopeType: f.Spec.ScopeType,
118117
scenarioVersion: f.Spec.ScenarioVersion,
119118
hash: f.hash,
120-
Simulated: f.Simulated,
121119
mutex: &sync.Mutex{},
122120
orderEvent: f.orderEvent,
123121
}

pkg/leakybucket/manager_load.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,17 @@ func (f *BucketFactory) Validate() error {
9797
return f.Spec.ScopeType.CompileFilter()
9898
}
9999

100+
type SimulationChecker interface {
101+
IsSimulated(scenario string) bool
102+
}
103+
100104
func loadBucketFactoriesFromFile(
101105
item *cwhub.Item,
102106
hub *cwhub.Hub,
103107
bucketStore *BucketStore,
104108
response chan pipeline.Event,
105109
orderEvent bool,
106-
simulationConfig csconfig.SimulationConfig,
110+
simcheck SimulationChecker,
107111
) ([]BucketFactory, error) {
108112
itemPath := item.State.LocalPath
109113

@@ -160,8 +164,7 @@ func loadBucketFactoriesFromFile(
160164
f.Filename = filepath.Clean(itemPath)
161165
f.BucketName = seed.Generate()
162166
f.ret = response
163-
164-
f.Simulated = simulationConfig.IsSimulated(f.Spec.Name)
167+
f.Simulated = simcheck.IsSimulated(f.Spec.Name)
165168

166169
f.Spec.ScenarioVersion = item.State.LocalVersion
167170
f.hash = item.State.LocalHash
@@ -192,7 +195,7 @@ func LoadBuckets(
192195
for _, item := range scenarios {
193196
log.Debugf("Loading '%s'", item.State.LocalPath)
194197

195-
factories, err := loadBucketFactoriesFromFile(item, hub, bucketStore, response, orderEvent, cscfg.SimulationConfig)
198+
factories, err := loadBucketFactoriesFromFile(item, hub, bucketStore, response, orderEvent, &cscfg.SimulationConfig)
196199
if err != nil {
197200
return nil, nil, err
198201
}

pkg/leakybucket/overflows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func NewAlert(leaky *Leaky, queue *pipeline.Queue) (pipeline.RuntimeAlert, error
316316
Message: new(string),
317317
StartAt: &startAt,
318318
StopAt: &stopAt,
319-
Simulated: &leaky.Simulated,
319+
Simulated: &leaky.BucketConfig.Simulated,
320320
}
321321

322322
if leaky.BucketConfig == nil {

0 commit comments

Comments
 (0)