search

package
v0.0.0-...-bfa2730 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
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 GetVirtualTagValues(tagName string) []string

func GetVirtualTagValuesV2

func GetVirtualTagValuesV2(tagName string) []*deeppb.TagValue

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 (sr *Results) AddBytesInspected(c uint64)

func (*Results) AddResult

func (sr *Results) AddResult(ctx context.Context, r *deeppb.SnapshotSearchMetadata) (quit bool)

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 (sr *Results) AddSnapshotInspected(c uint32)

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 (sr *Results) BlocksInspected() uint32

func (*Results) BlocksSkipped

func (sr *Results) BlocksSkipped() uint32

func (*Results) BytesInspected

func (sr *Results) BytesInspected() uint64

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) Error

func (sr *Results) Error() error

Error returns error set by SetError

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

func (sr *Results) Quit() bool

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

func (sr *Results) SetError(err error)

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 (sr *Results) SnapshotsInspected() uint32

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()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL