mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00
Harmony backports (#3581)
Backport a few things from Harmony. ### Pull Request Checklist <!-- Please read https://matrix-org.github.io/dendrite/development/contributing before submitting your pull request --> * [ ] I have added Go unit tests or [Complement integration tests](https://github.com/matrix-org/complement) for this PR _or_ I have justified why this PR doesn't need tests * [x] Pull request includes a [sign off below](https://element-hq.github.io/dendrite/development/contributing#sign-off) _or_ I have already signed off privately --------- Signed-off-by: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Co-authored-by: Kegan Dougal <7190048+kegsay@users.noreply.github.com>
This commit is contained in:
parent
c133596baf
commit
331a6f221b
4 changed files with 18 additions and 11 deletions
|
@ -264,7 +264,11 @@ func (w *worker) _next() {
|
|||
})
|
||||
msgs, err := w.subscription.Fetch(1, nats.Context(ctx))
|
||||
switch err {
|
||||
case nil:
|
||||
case nil, nats.ErrTimeout, context.DeadlineExceeded, context.Canceled:
|
||||
// Is the server shutting down? If so, stop processing.
|
||||
if w.r.ProcessContext.Context().Err() != nil {
|
||||
return
|
||||
}
|
||||
// Make sure that once we're done here, we queue up another call
|
||||
// to _next in the inbox.
|
||||
defer w.Act(nil, w._next)
|
||||
|
@ -275,11 +279,11 @@ func (w *worker) _next() {
|
|||
return
|
||||
}
|
||||
|
||||
case context.DeadlineExceeded, context.Canceled:
|
||||
// The context exceeded, so we've been waiting for more than a
|
||||
// minute for activity in this room. At this point we will shut
|
||||
// down the subscriber to free up resources. It'll get started
|
||||
// again if new activity happens.
|
||||
case nats.ErrConsumerDeleted, nats.ErrConsumerNotFound:
|
||||
// The consumer is gone, therefore it's reached the inactivity
|
||||
// threshold. Clean up and stop processing at this point, if a
|
||||
// new event comes in for this room then the ordered consumer
|
||||
// over the entire stream will recreate this anyway.
|
||||
if err = w.subscription.Unsubscribe(); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to unsubscribe to stream for room %q", w.roomID)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue