Documentation
¶
Index ¶
- Constants
- func NewRequest(baseURL string, query string) (*http.Request, error)
- func Search(query string, opts Opts, client api.Client, decoder Decoder) error
- type ChunkMatch
- type Decoder
- type EventAlert
- type EventCommitMatch
- type EventContentMatch
- type EventError
- type EventFilter
- type EventLineMatch
- type EventMatch
- type EventPathMatch
- type EventRepoMatch
- type EventSymbolMatch
- type Location
- type MatchType
- type Opts
- type Progress
- type ProposedQuery
- type Range
- type Skipped
- type SkippedReason
- type SkippedSeverity
- type SkippedSuggested
- type Symbol
- type Writer
- type WriterStat
Constants ¶
const ( // DocumentMatchLimit is when we found too many matches in a document, so // we stopped searching it. DocumentMatchLimit SkippedReason = "document-match-limit" // ShardMatchLimit is when we found too many matches in a // shard/repository, so we stopped searching it. ShardMatchLimit = "shard-match-limit" // RepositoryLimit is when we did not search a repository because the set // of repositories to search was too large. RepositoryLimit = "repository-limit" // ShardTimeout is when we ran out of time before searching a // shard/repository. ShardTimeout = "shard-timeout" // RepositoryCloning is when we could not search a repository because it // is not cloned. RepositoryCloning = "repository-cloning" // RepositoryMissing is when we could not search a repository because it // is not cloned and we failed to find it on the remote code host. RepositoryMissing = "repository-missing" // ExcludedFork is when we did not search a repository because it is a // fork. ExcludedFork = "repository-fork" // ExcludedArchive is when we did not search a repository because it is // archived. ExcludedArchive = "excluded-archive" )
Variables ¶
This section is empty.
Functions ¶
func NewRequest ¶
NewRequest returns an http.Request against the streaming API for query.
Types ¶
type ChunkMatch ¶
type Decoder ¶
type Decoder struct {
OnProgress func(*Progress)
OnMatches func([]EventMatch)
OnFilters func([]*EventFilter)
OnAlert func(*EventAlert)
OnError func(*EventError)
OnUnknown func(event, data []byte)
}
Decoder decodes streaming events from a Server Sent Event stream. We only support streams which are generated by Sourcegraph. IE this is not a fully compliant Server Sent Events decoder.
type EventAlert ¶
type EventAlert struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
ProposedQueries []ProposedQuery `json:"proposedQueries"`
}
EventAlert is GQL.SearchAlert. It replaces when sent to match existing behaviour.
type EventCommitMatch ¶
type EventCommitMatch struct {
// Type is always CommitMatchType. Included here for marshalling.
Type MatchType `json:"type"`
Icon string `json:"icon"`
Label string `json:"label"`
URL string `json:"url"`
Detail string `json:"detail"`
Content string `json:"content"`
// [line, character, length]
Ranges [][3]int32 `json:"ranges"`
}
EventCommitMatch is the generic results interface from GQL. There is a lot of potential data that may be useful here, and some thought needs to be put into what is actually useful in a commit result / or if we should have a "type" for that.
type EventContentMatch ¶
type EventContentMatch struct {
// Type is always ContentMatchType. Included here for marshalling.
Type MatchType `json:"type"`
Path string `json:"path"`
Repository string `json:"repository"`
Branches []string `json:"branches,omitempty"`
Commit string `json:"commit,omitempty"`
ChunkMatches []ChunkMatch `json:"chunkMatches"`
}
EventContentMatch is a subset of zoekt.FileMatch for our Event API.
type EventError ¶
type EventError struct {
Message string `json:"message"`
}
EventError emulates a JavaScript error with a message property as is returned when the search encounters an error.
type EventFilter ¶
type EventFilter struct {
Value string `json:"value"`
Label string `json:"label"`
Count int `json:"count"`
LimitHit bool `json:"limitHit"`
Kind string `json:"kind"`
}
EventFilter is a suggestion for a search filter. Currently has a 1-1 correspondance with the SearchFilter graphql type.
type EventLineMatch ¶
type EventLineMatch struct {
Line string `json:"line"`
LineNumber int32 `json:"lineNumber"`
OffsetAndLengths [][2]int32 `json:"offsetAndLengths"`
}
EventLineMatch is a subset of zoekt.LineMatch for our Event API.
type EventMatch ¶
type EventMatch interface {
// contains filtered or unexported methods
}
EventMatch is an interface which only the top level match event types implement. Use this for your results slice rather than interface{}.
type EventPathMatch ¶
type EventPathMatch struct {
// Type is always PathMatchType. Included here for marshalling.
Type MatchType `json:"type"`
Path string `json:"path"`
Repository string `json:"repository"`
Branches []string `json:"branches,omitempty"`
Commit string `json:"commit,omitempty"`
}
EventPathMatch is a subset of zoekt.FileMatch for our Event API.
type EventRepoMatch ¶
type EventRepoMatch struct {
// Type is always RepoMatchType. Included here for marshalling.
Type MatchType `json:"type"`
Repository string `json:"repository"`
Branches []string `json:"branches,omitempty"`
}
EventRepoMatch is a subset of zoekt.FileMatch for our Event API.
type EventSymbolMatch ¶
type EventSymbolMatch struct {
// Type is always SymbolMatchType. Included here for marshalling.
Type MatchType `json:"type"`
Path string `json:"path"`
Repository string `json:"repository"`
Branches []string `json:"branches,omitempty"`
Commit string `json:"commit,omitempty"`
Symbols []Symbol `json:"symbols"`
}
EventSymbolMatch is EventFileMatch but with Symbols instead of LineMatches
type MatchType ¶
type MatchType int
func (MatchType) MarshalJSON ¶
func (*MatchType) UnmarshalJSON ¶
type Progress ¶
type Progress struct {
// Done is true if this is a final progress event.
Done bool `json:"done"`
// RepositoriesCount is the number of repositories being searched. It is
// non-nil once the set of repositories has been resolved.
RepositoriesCount *int `json:"repositoriesCount,omitempty"`
// MatchCount is number of non-overlapping matches. If skipped is
// non-empty, then this is a lower bound.
MatchCount int `json:"matchCount"`
// DurationMs is the wall clock time in milliseconds for this search.
DurationMs int `json:"durationMs"`
// Skipped is a description of shards or documents that were skipped. This
// has a deterministic ordering. More important reasons will be listed
// first. If a search is repeated, the final skipped list will be the
// same. However, within a search stream when a new skipped reason is
// found, it may appear anywhere in the list.
Skipped []Skipped `json:"skipped"`
}
Progress is an aggregate type representing a progress update.
type ProposedQuery ¶
type ProposedQuery struct {
Description string `json:"description,omitempty"`
Query string `json:"query"`
}
ProposedQuery is a suggested query to run when we emit an alert.
type Skipped ¶
type Skipped struct {
// Reason is why a document/shard/repository was skipped. We group counts
// by reason. eg ShardTimeout
Reason SkippedReason `json:"reason"`
// Title is a short message. eg "1,200 timed out".
Title string `json:"title"`
// Message is a message to show the user. Usually includes information
// explaining the reason, count as well as a sample of the missing items.
Message string `json:"message"`
Severity SkippedSeverity `json:"severity"`
// Suggested is a query expression to remedy the skip. eg "archived:yes".
Suggested *SkippedSuggested `json:"suggested,omitempty"`
}
Skipped is a description of shards or documents that were skipped.
type SkippedSeverity ¶
type SkippedSeverity string
SkippedSeverity is an enum for Skipped.Severity.
const ( SeverityInfo SkippedSeverity = "info" SeverityWarn SkippedSeverity = "warn" )
type SkippedSuggested ¶
type SkippedSuggested struct {
Title string `json:"title"`
QueryExpression string `json:"queryExpression"`
}
SkippedSuggested is a query to suggest to the user to resolve the reason for skipping.
type Writer ¶
type Writer struct {
StatHook func(WriterStat)
// contains filtered or unexported fields
}