fleet/server/kolide/targets.go
Zachary Wasserman 0b612eedab Push query results and metadata over websocket connection (#519)
- New route `/api/v1/kolide/results/{id}` with upgrade to websocket connection
- Query results pushed over websocket as they are received from pubsub
- Target totals updates pushed over websocket every second
- New datastore method to support retrieiving target totals
- Websocket package includes helpers and patterns for communicating over websockets
2016-11-22 16:35:43 -08:00

35 lines
953 B
Go

package kolide
import (
"golang.org/x/net/context"
)
type TargetSearchResults struct {
Hosts []Host
Labels []Label
}
type TargetService interface {
// SearchTargets will accept a search query, a slice of IDs of hosts to omit,
// and a slice of IDs of labels to omit, and it will return a set of targets
// (hosts and label) which match the supplied search query.
SearchTargets(ctx context.Context, query string, selectedHostIDs []uint, selectedLabelIDs []uint) (*TargetSearchResults, error)
// CountHostsInTargets returns the count of hosts in the selected
// targets. The first return uint is the total number of hosts in the
// targets. The second return uint is the total online hosts.
CountHostsInTargets(ctx context.Context, hostIDs []uint, labelIDs []uint) (total uint, online uint, err error)
}
type TargetType int
const (
TargetLabel TargetType = iota
TargetHost
)
type Target struct {
Type TargetType
TargetID uint
}