Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resubscribe subsystems when their subscription is terminated #593

Merged
merged 1 commit into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/logs/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (p *proxy) Start(ctx context.Context) error {
p.Error(err, "caching log chunk")
}
}
return nil
return pubsub.ErrSubscriptionTerminated
}

// GetChunk attempts to retrieve a chunk from the cache before falling back to
Expand Down
2 changes: 1 addition & 1 deletion internal/notifications/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s *Notifier) Start(ctx context.Context) error {
s.Error(err, "handling event", "event", event.Type)
}
}
return nil
return pubsub.ErrSubscriptionTerminated
}

func (s *Notifier) handle(ctx context.Context, event pubsub.Event) error {
Expand Down
5 changes: 5 additions & 0 deletions internal/pubsub/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pubsub
import (
"context"
"encoding/json"
"errors"
"fmt"
"sync"

Expand All @@ -22,6 +23,10 @@ const (
subBufferSize = 100
)

// ErrSubscriptionTerminated is for use by subscribers to indicate that their
// subscription has been terminated by the broker.
var ErrSubscriptionTerminated = errors.New("broker terminated the subscription")

type (

// Broker is a pubsub Broker implemented using postgres' listen/notify
Expand Down
2 changes: 1 addition & 1 deletion internal/repo/purger.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (p *Purger) Start(ctx context.Context) error {
return err
}
}
return nil
return pubsub.ErrSubscriptionTerminated
}

func (p *Purger) deleteUnreferencedWebhooks(ctx context.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/run/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (r *Reporter) Start(ctx context.Context) error {
return err
}
}
return nil
return pubsub.ErrSubscriptionTerminated
}

func (r *Reporter) handleRun(ctx context.Context, run *Run) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,5 @@ func (s *scheduler) Start(ctx context.Context) error {
}
}
}
return nil
return pubsub.ErrSubscriptionTerminated
}