mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 12:14:08 -06:00
56c3875bb9
* Remove context.TODO() from services * Fix live test
33 lines
905 B
Go
33 lines
905 B
Go
package pipeline
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/services/live/managedstream"
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/data"
|
|
)
|
|
|
|
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
|
|
}
|
|
|
|
func (out *ManagedStreamFrameOutput) OutputFrame(ctx context.Context, vars Vars, frame *data.Frame) ([]*ChannelFrame, error) {
|
|
stream, err := out.managedStream.GetOrCreateStream(vars.OrgID, vars.Scope, vars.Namespace)
|
|
if err != nil {
|
|
logger.Error("Error getting stream", "error", err)
|
|
return nil, err
|
|
}
|
|
return nil, stream.Push(ctx, vars.Path, frame)
|
|
}
|