mirror of https://github.com/grafana/loki
parent
101ef57ea2
commit
55d41b9519
@ -1,53 +0,0 @@ |
||||
package logql |
||||
|
||||
import ( |
||||
"context" |
||||
|
||||
"github.com/grafana/loki/pkg/iter" |
||||
"github.com/pkg/errors" |
||||
) |
||||
|
||||
// ChainedEvaluator is an evaluator which chains multiple other evaluators,
|
||||
// deferring to the first successful one.
|
||||
type ChainedEvaluator struct { |
||||
evaluators []Evaluator |
||||
} |
||||
|
||||
// StepEvaluator attempts the embedded evaluators until one succeeds or they all error.
|
||||
func (c *ChainedEvaluator) StepEvaluator( |
||||
ctx context.Context, |
||||
nextEvaluator Evaluator, |
||||
expr SampleExpr, |
||||
p Params, |
||||
) (stepper StepEvaluator, err error) { |
||||
for _, eval := range c.evaluators { |
||||
if stepper, err = eval.StepEvaluator(ctx, nextEvaluator, expr, p); err == nil { |
||||
return stepper, nil |
||||
} |
||||
} |
||||
return nil, err |
||||
} |
||||
|
||||
// Iterator attempts the embedded evaluators until one succeeds or they all error.
|
||||
func (c *ChainedEvaluator) Iterator( |
||||
ctx context.Context, |
||||
expr LogSelectorExpr, |
||||
p Params, |
||||
) (iterator iter.EntryIterator, err error) { |
||||
for _, eval := range c.evaluators { |
||||
if iterator, err = eval.Iterator(ctx, expr, p); err == nil { |
||||
return iterator, nil |
||||
} |
||||
} |
||||
return nil, err |
||||
} |
||||
|
||||
// NewChainedEvaluator constructs a ChainedEvaluator from one or more Evaluators
|
||||
func NewChainedEvaluator(evals ...Evaluator) (*ChainedEvaluator, error) { |
||||
if len(evals) == 0 { |
||||
return nil, errors.New("must supply an Evaluator") |
||||
} |
||||
return &ChainedEvaluator{ |
||||
evaluators: evals, |
||||
}, nil |
||||
} |
||||
@ -1,7 +0,0 @@ |
||||
package logql |
||||
|
||||
// Downstreamer is an interface for deferring responsibility for query execution.
|
||||
// It is decoupled from but consumed by a downStreamEvaluator to dispatch ASTs.
|
||||
type Downstreamer interface { |
||||
// Downstream(*LokiRequest) (*LokiResponse, error)
|
||||
} |
||||
Loading…
Reference in new issue