mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +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.
33 lines
717 B
Go
33 lines
717 B
Go
package live_query
|
|
|
|
import (
|
|
"github.com/kolide/fleet/server/kolide"
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
type MockLiveQuery struct {
|
|
mock.Mock
|
|
kolide.LiveQueryStore
|
|
}
|
|
|
|
func (m *MockLiveQuery) RunQuery(name, sql string, hostIDs []uint) error {
|
|
args := m.Called(name, sql, hostIDs)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *MockLiveQuery) StopQuery(name string) error {
|
|
args := m.Called(name)
|
|
return args.Error(0)
|
|
|
|
}
|
|
|
|
func (m *MockLiveQuery) QueriesForHost(hostID uint) (map[string]string, error) {
|
|
args := m.Called(hostID)
|
|
return args.Get(0).(map[string]string), args.Error(1)
|
|
}
|
|
|
|
func (m *MockLiveQuery) QueryCompletedByHost(name string, hostID uint) error {
|
|
args := m.Called(name, hostID)
|
|
return args.Error(0)
|
|
}
|