2021-10-06 12:43:25 -05:00
|
|
|
package pipeline
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/data"
|
2023-01-30 02:57:50 -06:00
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/services/live/managedstream"
|
2021-10-06 12:43:25 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type ManagedStreamFrameOutput struct {
|
|
|
|
managedStream *managedstream.Runner
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewManagedStreamFrameOutput(managedStream *managedstream.Runner) *ManagedStreamFrameOutput {
|
|
|
|
return &ManagedStreamFrameOutput{managedStream: managedStream}
|
|
|
|
}
|
|
|
|
|
|
|
|
const FrameOutputTypeManagedStream = "managedStream"
|
|
|
|
|
|
|
|
func (out *ManagedStreamFrameOutput) Type() string {
|
|
|
|
return FrameOutputTypeManagedStream
|
|
|
|
}
|
|
|
|
|
2021-12-28 03:26:18 -06:00
|
|
|
func (out *ManagedStreamFrameOutput) OutputFrame(ctx context.Context, vars Vars, frame *data.Frame) ([]*ChannelFrame, error) {
|
2021-10-06 12:43:25 -05:00
|
|
|
stream, err := out.managedStream.GetOrCreateStream(vars.OrgID, vars.Scope, vars.Namespace)
|
|
|
|
if err != nil {
|
|
|
|
logger.Error("Error getting stream", "error", err)
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-12-28 03:26:18 -06:00
|
|
|
return nil, stream.Push(ctx, vars.Path, frame)
|
2021-10-06 12:43:25 -05:00
|
|
|
}
|