fleet/server/pubsub/doc.go
Zachary Wasserman 39ebd81dc5 Close orphaned distributed query campaign after failed publish attempt (#707)
A distributed query campaign can be "orphaned" (left in the QueryRunning state)
if the Kolide server restarts while it is running, or other weirdness occurs.
When this happens, no subscribers are waiting to read results written by
osqueryd agents, but the agents continue to receive the query. Previously, this
would cause us to error on ingestion.

The new behavior will instead set the campaign to completed when it detects
that it is orphaned. This should prevent sending queries for which there is no
subscriber.

- New NoSubscriber error interface in pubsub
- Detect NoSubscriber errors and close campaigns
- Tests on pubsub and service methods

Fixes #695
2016-12-27 10:35:19 -05:00

25 lines
682 B
Go

// Package pubsub implements pub/sub interfaces defined in package kolide.
package pubsub
// Error defines the interface of errors specific to the pubsub package
type Error interface {
error
// NoSubscriber returns true if the error occurred because there are no
// subscribers on the channel
NoSubscriber() bool
}
// NoSubscriberError can be returned when channel operations fail because there
// are no subscribers. Its NoSubscriber() method always returns true.
type noSubscriberError struct {
Channel string
}
func (e noSubscriberError) Error() string {
return "no subscriber for channel " + e.Channel
}
func (e noSubscriberError) NoSubscriber() bool {
return true
}