@@ -11,31 +11,31 @@ import (
1111 "github.com/smartcontractkit/chainlink-testing-framework/wasp"
1212)
1313
14- type GeneratorQueryFn = func (responses * wasp.SliceBuffer [wasp.Response ]) (float64 , error )
14+ type DirectQueryFn = func (responses * wasp.SliceBuffer [wasp.Response ]) (float64 , error )
1515
16- type GeneratorQueryExecutor struct {
17- KindName string `json:"kind"`
18- Generator * wasp.Generator `json:"generator_config"`
19- Queries map [string ]GeneratorQueryFn `json:"queries"`
20- QueryResults map [string ]interface {} `json:"query_results"`
16+ type DirectQueryExecutor struct {
17+ KindName string `json:"kind"`
18+ Generator * wasp.Generator `json:"generator_config"`
19+ Queries map [string ]DirectQueryFn `json:"queries"`
20+ QueryResults map [string ]interface {} `json:"query_results"`
2121}
2222
23- func NewStandardGeneratorQueryExecutor (generator * wasp.Generator ) (* GeneratorQueryExecutor , error ) {
24- g := & GeneratorQueryExecutor {
25- KindName : string (StandardQueryExecutor_Generator ),
23+ func NewStandardDirectQueryExecutor (generator * wasp.Generator ) (* DirectQueryExecutor , error ) {
24+ g := & DirectQueryExecutor {
25+ KindName : string (StandardQueryExecutor_Direct ),
2626 }
2727
2828 queries , err := g .generateStandardQueries ()
2929 if err != nil {
3030 return nil , err
3131 }
3232
33- return NewGeneratorQueryExecutor (generator , queries )
33+ return NewDirectQueryExecutor (generator , queries )
3434}
3535
36- func NewGeneratorQueryExecutor (generator * wasp.Generator , queries map [string ]GeneratorQueryFn ) (* GeneratorQueryExecutor , error ) {
37- g := & GeneratorQueryExecutor {
38- KindName : string (StandardQueryExecutor_Generator ),
36+ func NewDirectQueryExecutor (generator * wasp.Generator , queries map [string ]DirectQueryFn ) (* DirectQueryExecutor , error ) {
37+ g := & DirectQueryExecutor {
38+ KindName : string (StandardQueryExecutor_Direct ),
3939 Generator : generator ,
4040 Queries : queries ,
4141 QueryResults : make (map [string ]interface {}),
@@ -44,22 +44,22 @@ func NewGeneratorQueryExecutor(generator *wasp.Generator, queries map[string]Gen
4444 return g , nil
4545}
4646
47- func (g * GeneratorQueryExecutor ) Results () map [string ]interface {} {
47+ func (g * DirectQueryExecutor ) Results () map [string ]interface {} {
4848 return g .QueryResults
4949}
5050
51- func (l * GeneratorQueryExecutor ) Kind () string {
51+ func (l * DirectQueryExecutor ) Kind () string {
5252 return l .KindName
5353}
5454
55- func (g * GeneratorQueryExecutor ) IsComparable (otherQueryExecutor QueryExecutor ) error {
55+ func (g * DirectQueryExecutor ) IsComparable (otherQueryExecutor QueryExecutor ) error {
5656 otherType := reflect .TypeOf (otherQueryExecutor )
5757
5858 if otherType != reflect .TypeOf (g ) {
5959 return fmt .Errorf ("expected type %s, got %s" , reflect .TypeOf (g ), otherType )
6060 }
6161
62- otherGeneratorQueryExecutor := otherQueryExecutor .(* GeneratorQueryExecutor )
62+ otherGeneratorQueryExecutor := otherQueryExecutor .(* DirectQueryExecutor )
6363
6464 if compareGeneratorConfigs (g .Generator .Cfg , otherGeneratorQueryExecutor .Generator .Cfg ) != nil {
6565 return errors .New ("generators are not comparable" )
@@ -68,7 +68,7 @@ func (g *GeneratorQueryExecutor) IsComparable(otherQueryExecutor QueryExecutor)
6868 return g .compareQueries (otherGeneratorQueryExecutor .Queries )
6969}
7070
71- func (l * GeneratorQueryExecutor ) compareQueries (other map [string ]GeneratorQueryFn ) error {
71+ func (l * DirectQueryExecutor ) compareQueries (other map [string ]DirectQueryFn ) error {
7272 this := l .Queries
7373 if len (this ) != len (other ) {
7474 return fmt .Errorf ("queries count is different. Expected %d, got %d" , len (this ), len (other ))
@@ -83,7 +83,7 @@ func (l *GeneratorQueryExecutor) compareQueries(other map[string]GeneratorQueryF
8383 return nil
8484}
8585
86- func (g * GeneratorQueryExecutor ) Validate () error {
86+ func (g * DirectQueryExecutor ) Validate () error {
8787 if g .Generator == nil {
8888 return errors .New ("generator is not set" )
8989 }
@@ -95,7 +95,7 @@ func (g *GeneratorQueryExecutor) Validate() error {
9595 return nil
9696}
9797
98- func (g * GeneratorQueryExecutor ) Execute (_ context.Context ) error {
98+ func (g * DirectQueryExecutor ) Execute (_ context.Context ) error {
9999 if g .Generator == nil {
100100 return errors .New ("generator is not set" )
101101 }
@@ -130,12 +130,12 @@ func (g *GeneratorQueryExecutor) Execute(_ context.Context) error {
130130 return nil
131131}
132132
133- func (g * GeneratorQueryExecutor ) TimeRange (_ , _ time.Time ) {
133+ func (g * DirectQueryExecutor ) TimeRange (_ , _ time.Time ) {
134134 // nothing to do here, since all responses stored in the generator are already in the right time range
135135}
136136
137- func (g * GeneratorQueryExecutor ) generateStandardQueries () (map [string ]GeneratorQueryFn , error ) {
138- standardQueries := make (map [string ]GeneratorQueryFn )
137+ func (g * DirectQueryExecutor ) generateStandardQueries () (map [string ]DirectQueryFn , error ) {
138+ standardQueries := make (map [string ]DirectQueryFn )
139139
140140 for _ , metric := range standardLoadMetrics {
141141 query , err := g .standardQuery (metric )
@@ -148,7 +148,7 @@ func (g *GeneratorQueryExecutor) generateStandardQueries() (map[string]Generator
148148 return standardQueries , nil
149149}
150150
151- func (g * GeneratorQueryExecutor ) standardQuery (standardMetric StandardLoadMetric ) (GeneratorQueryFn , error ) {
151+ func (g * DirectQueryExecutor ) standardQuery (standardMetric StandardLoadMetric ) (DirectQueryFn , error ) {
152152 switch standardMetric {
153153 case MedianLatency :
154154 medianFn := func (responses * wasp.SliceBuffer [wasp.Response ]) (float64 , error ) {
@@ -194,7 +194,7 @@ func (g *GeneratorQueryExecutor) standardQuery(standardMetric StandardLoadMetric
194194 }
195195}
196196
197- func (g * GeneratorQueryExecutor ) MarshalJSON () ([]byte , error ) {
197+ func (g * DirectQueryExecutor ) MarshalJSON () ([]byte , error ) {
198198 // we need custom marshalling to only include query names, since the functions are not serializable
199199 type QueryExecutor struct {
200200 Kind string `json:"kind"`
@@ -222,10 +222,10 @@ func (g *GeneratorQueryExecutor) MarshalJSON() ([]byte, error) {
222222 })
223223}
224224
225- func (g * GeneratorQueryExecutor ) UnmarshalJSON (data []byte ) error {
225+ func (g * DirectQueryExecutor ) UnmarshalJSON (data []byte ) error {
226226 // helper struct with QueryExecutors as json.RawMessage and QueryResults as map[string]interface{}
227227 // and as actual types
228- type Alias GeneratorQueryExecutor
228+ type Alias DirectQueryExecutor
229229 var raw struct {
230230 Alias
231231 GeneratorCfg wasp.Config `json:"generator_config"`
@@ -238,7 +238,7 @@ func (g *GeneratorQueryExecutor) UnmarshalJSON(data []byte) error {
238238 return err
239239 }
240240
241- queries := make (map [string ]GeneratorQueryFn )
241+ queries := make (map [string ]DirectQueryFn )
242242
243243 // unmarshall only query names
244244 for _ , rawQuery := range raw .Queries {
@@ -256,7 +256,7 @@ func (g *GeneratorQueryExecutor) UnmarshalJSON(data []byte) error {
256256 return conversionErr
257257 }
258258
259- * g = GeneratorQueryExecutor (raw .Alias )
259+ * g = DirectQueryExecutor (raw .Alias )
260260 g .Queries = queries
261261 g .QueryResults = convertedTypes
262262 g .Generator = & wasp.Generator {
0 commit comments