UseRunStream is a default behaviour (#34021)

This commit is contained in:
Alexander Emelin
2021-05-12 22:17:31 +03:00
committed by GitHub
parent 64f31a8d6f
commit a14ae53347
4 changed files with 17 additions and 19 deletions
+10 -12
View File
@@ -81,21 +81,19 @@ func (r *PluginPathRunner) OnSubscribe(ctx context.Context, user *models.SignedI
return models.SubscribeReply{}, resp.Status, nil
}
if resp.UseRunStream {
submitResult, err := r.runStreamManager.SubmitStream(ctx, user.OrgId, e.Channel, r.path, pCtx, r.handler)
if err != nil {
logger.Error("Error submitting stream to manager", "error", err, "path", r.path)
return models.SubscribeReply{}, 0, centrifuge.ErrorInternal
}
if submitResult.StreamExists {
logger.Debug("Skip running new stream (already exists)", "path", r.path)
} else {
logger.Debug("Running a new keepalive stream", "path", r.path)
}
submitResult, err := r.runStreamManager.SubmitStream(ctx, user.OrgId, e.Channel, r.path, pCtx, r.handler)
if err != nil {
logger.Error("Error submitting stream to manager", "error", err, "path", r.path)
return models.SubscribeReply{}, 0, centrifuge.ErrorInternal
}
if submitResult.StreamExists {
logger.Debug("Skip running new stream (already exists)", "path", r.path)
} else {
logger.Debug("Running a new keepalive stream", "path", r.path)
}
reply := models.SubscribeReply{
Presence: resp.UseRunStream, // only enable presence for streams with UseRunStream on at the moment.
Presence: true,
Data: resp.Data,
}
return reply, backend.SubscribeStreamStatusOK, nil
+2 -3
View File
@@ -38,9 +38,8 @@ func (p *testStreamHandler) SubscribeStream(_ context.Context, req *backend.Subs
}
p.logger.Debug("Allowing access to stream", "path", req.Path, "user", req.PluginContext.User)
return &backend.SubscribeStreamResponse{
Status: backend.SubscribeStreamStatusOK,
Data: schema,
UseRunStream: true,
Status: backend.SubscribeStreamStatusOK,
Data: schema,
}, nil
}