mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Live: proxy subscribe data for subscribe and runstream plugin calls (#42824)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
@@ -107,7 +107,7 @@ type FrameOutputter interface {
|
||||
// Subscriber can handle channel subscribe events.
|
||||
type Subscriber interface {
|
||||
Type() string
|
||||
Subscribe(ctx context.Context, vars Vars) (models.SubscribeReply, backend.SubscribeStreamStatus, error)
|
||||
Subscribe(ctx context.Context, vars Vars, data []byte) (models.SubscribeReply, backend.SubscribeStreamStatus, error)
|
||||
}
|
||||
|
||||
// PublishAuthChecker checks whether current user can publish to a channel.
|
||||
|
||||
@@ -28,7 +28,7 @@ func (s *BuiltinSubscriber) Type() string {
|
||||
return SubscriberTypeBuiltin
|
||||
}
|
||||
|
||||
func (s *BuiltinSubscriber) Subscribe(ctx context.Context, vars Vars) (models.SubscribeReply, backend.SubscribeStreamStatus, error) {
|
||||
func (s *BuiltinSubscriber) Subscribe(ctx context.Context, vars Vars, data []byte) (models.SubscribeReply, backend.SubscribeStreamStatus, error) {
|
||||
u, ok := livecontext.GetContextSignedUser(ctx)
|
||||
if !ok {
|
||||
return models.SubscribeReply{}, backend.SubscribeStreamStatusPermissionDenied, nil
|
||||
@@ -40,5 +40,6 @@ func (s *BuiltinSubscriber) Subscribe(ctx context.Context, vars Vars) (models.Su
|
||||
return handler.OnSubscribe(ctx, u, models.SubscribeEvent{
|
||||
Channel: vars.Channel,
|
||||
Path: vars.Path,
|
||||
Data: data,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func (s *ManagedStreamSubscriber) Type() string {
|
||||
return SubscriberTypeManagedStream
|
||||
}
|
||||
|
||||
func (s *ManagedStreamSubscriber) Subscribe(ctx context.Context, vars Vars) (models.SubscribeReply, backend.SubscribeStreamStatus, error) {
|
||||
func (s *ManagedStreamSubscriber) Subscribe(ctx context.Context, vars Vars, _ []byte) (models.SubscribeReply, backend.SubscribeStreamStatus, error) {
|
||||
stream, err := s.managedStream.GetOrCreateStream(vars.OrgID, vars.Scope, vars.Namespace)
|
||||
if err != nil {
|
||||
logger.Error("Error getting managed stream", "error", err)
|
||||
|
||||
@@ -21,11 +21,11 @@ func (s *MultipleSubscriber) Type() string {
|
||||
return SubscriberTypeMultiple
|
||||
}
|
||||
|
||||
func (s *MultipleSubscriber) Subscribe(ctx context.Context, vars Vars) (models.SubscribeReply, backend.SubscribeStreamStatus, error) {
|
||||
func (s *MultipleSubscriber) Subscribe(ctx context.Context, vars Vars, data []byte) (models.SubscribeReply, backend.SubscribeStreamStatus, error) {
|
||||
finalReply := models.SubscribeReply{}
|
||||
|
||||
for _, s := range s.Subscribers {
|
||||
reply, status, err := s.Subscribe(ctx, vars)
|
||||
reply, status, err := s.Subscribe(ctx, vars, data)
|
||||
if err != nil {
|
||||
return models.SubscribeReply{}, 0, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user