Documentation
¶
Index ¶
- Constants
- func CombineSearchResults(existing *deeppb.SnapshotSearchMetadata, ...)
- func GetVirtualTagValues(tagName string) []string
- func GetVirtualTagValuesV2(tagName string) []*deeppb.TagValue
- type Results
- func (sr *Results) AddBlockInspected()
- func (sr *Results) AddBlockSkipped()
- func (sr *Results) AddBytesInspected(c uint64)
- func (sr *Results) AddResult(ctx context.Context, r *deeppb.SnapshotSearchMetadata) (quit bool)
- func (sr *Results) AddSnapshotInspected(c uint32)
- func (sr *Results) AllWorkersStarted()
- func (sr *Results) BlocksInspected() uint32
- func (sr *Results) BlocksSkipped() uint32
- func (sr *Results) BytesInspected() uint64
- func (sr *Results) Close()
- func (sr *Results) Error() error
- func (sr *Results) FinishWorker()
- func (sr *Results) Quit() bool
- func (sr *Results) Results() <-chan *deeppb.SnapshotSearchMetadata
- func (sr *Results) SetError(err error)
- func (sr *Results) SnapshotsInspected() uint32
- func (sr *Results) StartWorker()
Constants ¶
const ( ErrorTag = "error" StatusCodeTag = "status.code" StatusCodeUnset = "unset" StatusCodeOK = "ok" StatusCodeError = "error" )
Variables ¶
This section is empty.
Functions ¶
func CombineSearchResults ¶
func CombineSearchResults(existing *deeppb.SnapshotSearchMetadata, incoming *deeppb.SnapshotSearchMetadata)
CombineSearchResults overlays the incoming search result with the existing result. This is required for the following reason: a snapshot may be present in multiple blocks, or in partial segments in live snapshot. The results should reflect elements of all segments.
func GetVirtualTagValues ¶
func GetVirtualTagValuesV2 ¶
Types ¶
type Results ¶
type Results struct {
// contains filtered or unexported fields
}
Results eases performing a highly parallel search by funneling all results into a single channel that is easy to consume, signaling workers to quit early as needed, and collecting metrics.
func NewResults ¶
func NewResults() *Results
func (*Results) AddBlockInspected ¶
func (sr *Results) AddBlockInspected()
func (*Results) AddBlockSkipped ¶
func (sr *Results) AddBlockSkipped()
func (*Results) AddBytesInspected ¶
func (*Results) AddResult ¶
AddResult sends a search result from a search task (goroutine) to the receiver of the search results, i.e. the initiator of the search. This function blocks until there is buffer space in the results channel or if the task should stop searching because the receiver went away or the given context is done. In this case true is returned.
func (*Results) AddSnapshotInspected ¶
func (*Results) AllWorkersStarted ¶
func (sr *Results) AllWorkersStarted()
AllWorkersStarted indicates that no more workers (senders) will be launched, and the results channel can be closed once the number of workers reaches zero. This function call occurs after all calls to StartWorker.
func (*Results) BlocksInspected ¶
func (*Results) BlocksSkipped ¶
func (*Results) BytesInspected ¶
func (*Results) Close ¶
func (sr *Results) Close()
Close signals to all workers to quit, when max results is received and no more work is needed. Called by the initiator of the search in a defer statement like: sr := NewSearchResults() defer sr.Close()
func (*Results) FinishWorker ¶
func (sr *Results) FinishWorker()
FinishWorker indicates a sender (goroutine) is done searching and will not send any more search results. When the last sender is finished, the results channel is closed.
func (*Results) Quit ¶
Quit returns if search tasks should quit early. This can occur due to max results already found, or other errors such as timeout, etc.
func (*Results) Results ¶
func (sr *Results) Results() <-chan *deeppb.SnapshotSearchMetadata
Results returns the results channel. Channel is closed when the search is complete. Can be iterated by range like: for res := range sr.Results()
func (*Results) SetError ¶
SetError will set error in a thread safe manner.
NOTE: this will ignore common.Unsupported errors, we don't Propagate those error upstream.
func (*Results) SnapshotsInspected ¶
func (*Results) StartWorker ¶
func (sr *Results) StartWorker()
StartWorker indicates another sender will be using the results channel. Must be followed with a call to FinishWorker which is usually deferred in a goroutine: sr.StartWorker() go func() { defer sr.FinishWorker()