mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
0502412e15
This change optimizes live queries by pushing the computation of query targets to the creation time of the query, and efficiently caching the targets in Redis. This results in a huge performance improvement at both steady-state, and when running live queries. - Live queries are stored using a bitfield in Redis, and takes advantage of bitfield operations to be extremely efficient. - Only run Redis live query test when REDIS_TEST is set in environment - Ensure that live queries are only sent to hosts when there is a client listening for results. Addresses an existing issue in Fleet along with appropriate cleanup for the refactored live query backend.
20 lines
881 B
Go
20 lines
881 B
Go
package kolide
|
|
|
|
// LiveQueryStore defines an interface for storing and retrieving the status of
|
|
// live queries in the Fleet system.
|
|
type LiveQueryStore interface {
|
|
// RunQuery starts a query with the given name and SQL, targeting the
|
|
// provided host IDs.
|
|
RunQuery(name, sql string, hostIDs []uint) error
|
|
// StopQuery stops a running query with the given name. Hosts will no longer
|
|
// receive the query after StopQuery has been called.
|
|
StopQuery(name string) error
|
|
// QueriesForHost returns the active queries for the given host ID. The
|
|
// return value maps from query name to SQL.
|
|
QueriesForHost(hostID uint) (map[string]string, error)
|
|
// QueryCompletedByHost marks the query with the given name as completed by the
|
|
// given host. After calling QueryCompleted, that query will no longer be
|
|
// sent to the host.
|
|
QueryCompletedByHost(name string, hostID uint) error
|
|
}
|