mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Live: array for Processor, Outputter and Subscriber in channel rule top level (#39677)
This commit is contained in:
36
pkg/services/live/pipeline/frame_output_multiple.go
Normal file
36
pkg/services/live/pipeline/frame_output_multiple.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
)
|
||||
|
||||
// MultipleFrameOutput can combine several FrameOutputter and
|
||||
// execute them sequentially.
|
||||
type MultipleFrameOutput struct {
|
||||
Outputters []FrameOutputter
|
||||
}
|
||||
|
||||
const FrameOutputTypeMultiple = "multiple"
|
||||
|
||||
func (out *MultipleFrameOutput) Type() string {
|
||||
return FrameOutputTypeMultiple
|
||||
}
|
||||
|
||||
func (out MultipleFrameOutput) OutputFrame(ctx context.Context, vars Vars, frame *data.Frame) ([]*ChannelFrame, error) {
|
||||
var frames []*ChannelFrame
|
||||
for _, out := range out.Outputters {
|
||||
f, err := out.OutputFrame(ctx, vars, frame)
|
||||
if err != nil {
|
||||
logger.Error("Error outputting frame", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
frames = append(frames, f...)
|
||||
}
|
||||
return frames, nil
|
||||
}
|
||||
|
||||
func NewMultipleFrameOutput(outputters ...FrameOutputter) *MultipleFrameOutput {
|
||||
return &MultipleFrameOutput{Outputters: outputters}
|
||||
}
|
||||
Reference in New Issue
Block a user