Skip to content
This repository has been archived by the owner on May 29, 2018. It is now read-only.

Add fields needed for search pagination #68

Merged
merged 6 commits into from
Oct 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions sourcegraph/cached_grpc.pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -3312,6 +3312,28 @@ func (s *CachedSearchServer) Search(ctx context.Context, in *SearchOptions) (*Se
return result, err
}

func (s *CachedSearchServer) SearchTokens(ctx context.Context, in *TokenSearchOptions) (*DefList, error) {
ctx, cc := grpccache.Internal_WithCacheControl(ctx)
result, err := s.SearchServer.SearchTokens(ctx, in)
if !cc.IsZero() {
if err := grpccache.Internal_SetCacheControlTrailer(ctx, *cc); err != nil {
return nil, err
}
}
return result, err
}

func (s *CachedSearchServer) SearchText(ctx context.Context, in *TextSearchOptions) (*VCSSearchResultList, error) {
ctx, cc := grpccache.Internal_WithCacheControl(ctx)
result, err := s.SearchServer.SearchText(ctx, in)
if !cc.IsZero() {
if err := grpccache.Internal_SetCacheControlTrailer(ctx, *cc); err != nil {
return nil, err
}
}
return result, err
}

func (s *CachedSearchServer) Complete(ctx context.Context, in *RawQuery) (*Completions, error) {
ctx, cc := grpccache.Internal_WithCacheControl(ctx)
result, err := s.SearchServer.Complete(ctx, in)
Expand Down Expand Up @@ -3365,6 +3387,58 @@ func (s *CachedSearchClient) Search(ctx context.Context, in *SearchOptions, opts
return result, nil
}

func (s *CachedSearchClient) SearchTokens(ctx context.Context, in *TokenSearchOptions, opts ...grpc.CallOption) (*DefList, error) {
if s.Cache != nil {
var cachedResult DefList
cached, err := s.Cache.Get(ctx, "Search.SearchTokens", in, &cachedResult)
if err != nil {
return nil, err
}
if cached {
return &cachedResult, nil
}
}

var trailer metadata.MD

result, err := s.SearchClient.SearchTokens(ctx, in, grpc.Trailer(&trailer))
if err != nil {
return nil, err
}
if s.Cache != nil {
if err := s.Cache.Store(ctx, "Search.SearchTokens", in, result, trailer); err != nil {
return nil, err
}
}
return result, nil
}

func (s *CachedSearchClient) SearchText(ctx context.Context, in *TextSearchOptions, opts ...grpc.CallOption) (*VCSSearchResultList, error) {
if s.Cache != nil {
var cachedResult VCSSearchResultList
cached, err := s.Cache.Get(ctx, "Search.SearchText", in, &cachedResult)
if err != nil {
return nil, err
}
if cached {
return &cachedResult, nil
}
}

var trailer metadata.MD

result, err := s.SearchClient.SearchText(ctx, in, grpc.Trailer(&trailer))
if err != nil {
return nil, err
}
if s.Cache != nil {
if err := s.Cache.Store(ctx, "Search.SearchText", in, result, trailer); err != nil {
return nil, err
}
}
return result, nil
}

func (s *CachedSearchClient) Complete(ctx context.Context, in *RawQuery, opts ...grpc.CallOption) (*Completions, error) {
if s.Cache != nil {
var cachedResult Completions
Expand Down
32 changes: 26 additions & 6 deletions sourcegraph/mock/sourcegraph.pb_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -942,15 +942,25 @@ func (s *RepoTreeServer) List(v0 context.Context, v1 *sourcegraph.RepoTreeListOp
var _ sourcegraph.RepoTreeServer = (*RepoTreeServer)(nil)

type SearchClient struct {
Search_ func(ctx context.Context, in *sourcegraph.SearchOptions) (*sourcegraph.SearchResults, error)
Complete_ func(ctx context.Context, in *sourcegraph.RawQuery) (*sourcegraph.Completions, error)
Suggest_ func(ctx context.Context, in *sourcegraph.RawQuery) (*sourcegraph.SuggestionList, error)
Search_ func(ctx context.Context, in *sourcegraph.SearchOptions) (*sourcegraph.SearchResults, error)
SearchTokens_ func(ctx context.Context, in *sourcegraph.TokenSearchOptions) (*sourcegraph.DefList, error)
SearchText_ func(ctx context.Context, in *sourcegraph.TextSearchOptions) (*sourcegraph.VCSSearchResultList, error)
Complete_ func(ctx context.Context, in *sourcegraph.RawQuery) (*sourcegraph.Completions, error)
Suggest_ func(ctx context.Context, in *sourcegraph.RawQuery) (*sourcegraph.SuggestionList, error)
}

func (s *SearchClient) Search(ctx context.Context, in *sourcegraph.SearchOptions, opts ...grpc.CallOption) (*sourcegraph.SearchResults, error) {
return s.Search_(ctx, in)
}

func (s *SearchClient) SearchTokens(ctx context.Context, in *sourcegraph.TokenSearchOptions, opts ...grpc.CallOption) (*sourcegraph.DefList, error) {
return s.SearchTokens_(ctx, in)
}

func (s *SearchClient) SearchText(ctx context.Context, in *sourcegraph.TextSearchOptions, opts ...grpc.CallOption) (*sourcegraph.VCSSearchResultList, error) {
return s.SearchText_(ctx, in)
}

func (s *SearchClient) Complete(ctx context.Context, in *sourcegraph.RawQuery, opts ...grpc.CallOption) (*sourcegraph.Completions, error) {
return s.Complete_(ctx, in)
}
Expand All @@ -962,15 +972,25 @@ func (s *SearchClient) Suggest(ctx context.Context, in *sourcegraph.RawQuery, op
var _ sourcegraph.SearchClient = (*SearchClient)(nil)

type SearchServer struct {
Search_ func(v0 context.Context, v1 *sourcegraph.SearchOptions) (*sourcegraph.SearchResults, error)
Complete_ func(v0 context.Context, v1 *sourcegraph.RawQuery) (*sourcegraph.Completions, error)
Suggest_ func(v0 context.Context, v1 *sourcegraph.RawQuery) (*sourcegraph.SuggestionList, error)
Search_ func(v0 context.Context, v1 *sourcegraph.SearchOptions) (*sourcegraph.SearchResults, error)
SearchTokens_ func(v0 context.Context, v1 *sourcegraph.TokenSearchOptions) (*sourcegraph.DefList, error)
SearchText_ func(v0 context.Context, v1 *sourcegraph.TextSearchOptions) (*sourcegraph.VCSSearchResultList, error)
Complete_ func(v0 context.Context, v1 *sourcegraph.RawQuery) (*sourcegraph.Completions, error)
Suggest_ func(v0 context.Context, v1 *sourcegraph.RawQuery) (*sourcegraph.SuggestionList, error)
}

func (s *SearchServer) Search(v0 context.Context, v1 *sourcegraph.SearchOptions) (*sourcegraph.SearchResults, error) {
return s.Search_(v0, v1)
}

func (s *SearchServer) SearchTokens(v0 context.Context, v1 *sourcegraph.TokenSearchOptions) (*sourcegraph.DefList, error) {
return s.SearchTokens_(v0, v1)
}

func (s *SearchServer) SearchText(v0 context.Context, v1 *sourcegraph.TextSearchOptions) (*sourcegraph.VCSSearchResultList, error) {
return s.SearchText_(v0, v1)
}

func (s *SearchServer) Complete(v0 context.Context, v1 *sourcegraph.RawQuery) (*sourcegraph.Completions, error) {
return s.Complete_(v0, v1)
}
Expand Down
88 changes: 87 additions & 1 deletion sourcegraph/sourcegraph.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions sourcegraph/sourcegraph.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ message ListOptions {
message ListResponse {
// HasMore is true if there are more entries available after the returned page.
bool has_more = 1 [(gogoproto.moretags) = "url:\",omitempty\""];

// Total is the total number of results in the list.
int32 total = 2 [(gogoproto.moretags) = "url:\",omitempty\""];
}

// Discussion stores information about a discussion
Expand Down Expand Up @@ -1844,6 +1847,7 @@ message DefsGetOp {

message DefList {
repeated Def defs = 1;
ListResponse list_response = 2 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
}

message DefsListRefsOp {
Expand Down Expand Up @@ -2180,8 +2184,20 @@ message RepoTreeListResult {

message VCSSearchResultList {
repeated vcs.SearchResult search_results = 1;
ListResponse list_response = 2 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
}

message TokenSearchOptions {
string query = 1 [(gogoproto.moretags) = "url:\"q\" schema:\"q\""];
ListOptions list_options = 2 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
}

message TextSearchOptions {
string query = 1 [(gogoproto.moretags) = "url:\"q\" schema:\"q\""];
ListOptions list_options = 2 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
}

// Deprecated.
message SearchOptions {
string query = 1 [(gogoproto.moretags) = "url:\"q\" schema:\"q\""];
bool defs = 2;
Expand All @@ -2191,6 +2207,7 @@ message SearchOptions {
ListOptions list_options = 6 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
}

// Deprecated.
message SearchResults {
repeated Def defs = 1;
repeated Person people = 2;
Expand Down Expand Up @@ -2481,12 +2498,27 @@ service RepoTree {
// API.
service Search {
// Search searches the full index.
// Deprecated: use one of the more specific search methods below.
rpc Search(SearchOptions) returns (SearchResults) {
option (google.api.http) = {
post: "/search"
};
};

// SearchTokens searches the index of tokens.
rpc SearchTokens(TokenSearchOptions) returns (DefList) {
option (google.api.http) = {
post: "/search/tokens"
};
};

// SearchText searches the content of files in the repo tree.
rpc SearchText(TextSearchOptions) returns (VCSSearchResultList) {
option (google.api.http) = {
post: "/search/text"
};
};

// Complete completes the token at the RawQuery's InsertionPoint.
rpc Complete(RawQuery) returns (Completions) {
option (google.api.http) = {
Expand Down