Live: declarative processing pipeline, input -> frames -> output, toggle protected POC (#37644)
This commit is contained in:
@@ -1,24 +1,42 @@
|
||||
package liveplugin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/plugins/plugincontext"
|
||||
"github.com/grafana/grafana/pkg/services/live/orgchannel"
|
||||
"github.com/grafana/grafana/pkg/services/live/pipeline"
|
||||
|
||||
"github.com/centrifugal/centrifuge"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
)
|
||||
|
||||
type ChannelLocalPublisher struct {
|
||||
node *centrifuge.Node
|
||||
node *centrifuge.Node
|
||||
pipeline *pipeline.Pipeline
|
||||
}
|
||||
|
||||
func NewChannelLocalPublisher(node *centrifuge.Node) *ChannelLocalPublisher {
|
||||
return &ChannelLocalPublisher{node: node}
|
||||
func NewChannelLocalPublisher(node *centrifuge.Node, pipeline *pipeline.Pipeline) *ChannelLocalPublisher {
|
||||
return &ChannelLocalPublisher{node: node, pipeline: pipeline}
|
||||
}
|
||||
|
||||
func (p *ChannelLocalPublisher) PublishLocal(channel string, data []byte) error {
|
||||
if p.pipeline != nil {
|
||||
orgID, channelID, err := orgchannel.StripOrgID(channel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ok, err := p.pipeline.ProcessInput(context.Background(), orgID, channelID, data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ok {
|
||||
// if rule found – we are done here. If not - fall through and process as usual.
|
||||
return nil
|
||||
}
|
||||
}
|
||||
pub := ¢rifuge.Publication{
|
||||
Data: data,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user