Live: declarative processing pipeline, input -> frames -> output, toggle protected POC (#37644)

This commit is contained in:
Alexander Emelin
2021-09-09 19:19:29 +03:00
committed by GitHub
parent d19f33b52f
commit 3ee861f57e
60 changed files with 5471 additions and 96 deletions
+21 -3
View File
@@ -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 := &centrifuge.Publication{
Data: data,
}