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

Commit 96d5770

Browse files
committed
Merge pull request #68 from sourcegraph/nodb-def-pagination
Add fields needed for search pagination
2 parents 15c2c24 + 72a6b38 commit 96d5770

File tree

4 files changed

+219
-7
lines changed

4 files changed

+219
-7
lines changed

sourcegraph/cached_grpc.pb.go

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3386,6 +3386,28 @@ func (s *CachedSearchServer) Search(ctx context.Context, in *SearchOptions) (*Se
33863386
return result, err
33873387
}
33883388

3389+
func (s *CachedSearchServer) SearchTokens(ctx context.Context, in *TokenSearchOptions) (*DefList, error) {
3390+
ctx, cc := grpccache.Internal_WithCacheControl(ctx)
3391+
result, err := s.SearchServer.SearchTokens(ctx, in)
3392+
if !cc.IsZero() {
3393+
if err := grpccache.Internal_SetCacheControlTrailer(ctx, *cc); err != nil {
3394+
return nil, err
3395+
}
3396+
}
3397+
return result, err
3398+
}
3399+
3400+
func (s *CachedSearchServer) SearchText(ctx context.Context, in *TextSearchOptions) (*VCSSearchResultList, error) {
3401+
ctx, cc := grpccache.Internal_WithCacheControl(ctx)
3402+
result, err := s.SearchServer.SearchText(ctx, in)
3403+
if !cc.IsZero() {
3404+
if err := grpccache.Internal_SetCacheControlTrailer(ctx, *cc); err != nil {
3405+
return nil, err
3406+
}
3407+
}
3408+
return result, err
3409+
}
3410+
33893411
func (s *CachedSearchServer) Complete(ctx context.Context, in *RawQuery) (*Completions, error) {
33903412
ctx, cc := grpccache.Internal_WithCacheControl(ctx)
33913413
result, err := s.SearchServer.Complete(ctx, in)
@@ -3439,6 +3461,58 @@ func (s *CachedSearchClient) Search(ctx context.Context, in *SearchOptions, opts
34393461
return result, nil
34403462
}
34413463

3464+
func (s *CachedSearchClient) SearchTokens(ctx context.Context, in *TokenSearchOptions, opts ...grpc.CallOption) (*DefList, error) {
3465+
if s.Cache != nil {
3466+
var cachedResult DefList
3467+
cached, err := s.Cache.Get(ctx, "Search.SearchTokens", in, &cachedResult)
3468+
if err != nil {
3469+
return nil, err
3470+
}
3471+
if cached {
3472+
return &cachedResult, nil
3473+
}
3474+
}
3475+
3476+
var trailer metadata.MD
3477+
3478+
result, err := s.SearchClient.SearchTokens(ctx, in, grpc.Trailer(&trailer))
3479+
if err != nil {
3480+
return nil, err
3481+
}
3482+
if s.Cache != nil {
3483+
if err := s.Cache.Store(ctx, "Search.SearchTokens", in, result, trailer); err != nil {
3484+
return nil, err
3485+
}
3486+
}
3487+
return result, nil
3488+
}
3489+
3490+
func (s *CachedSearchClient) SearchText(ctx context.Context, in *TextSearchOptions, opts ...grpc.CallOption) (*VCSSearchResultList, error) {
3491+
if s.Cache != nil {
3492+
var cachedResult VCSSearchResultList
3493+
cached, err := s.Cache.Get(ctx, "Search.SearchText", in, &cachedResult)
3494+
if err != nil {
3495+
return nil, err
3496+
}
3497+
if cached {
3498+
return &cachedResult, nil
3499+
}
3500+
}
3501+
3502+
var trailer metadata.MD
3503+
3504+
result, err := s.SearchClient.SearchText(ctx, in, grpc.Trailer(&trailer))
3505+
if err != nil {
3506+
return nil, err
3507+
}
3508+
if s.Cache != nil {
3509+
if err := s.Cache.Store(ctx, "Search.SearchText", in, result, trailer); err != nil {
3510+
return nil, err
3511+
}
3512+
}
3513+
return result, nil
3514+
}
3515+
34423516
func (s *CachedSearchClient) Complete(ctx context.Context, in *RawQuery, opts ...grpc.CallOption) (*Completions, error) {
34433517
if s.Cache != nil {
34443518
var cachedResult Completions

sourcegraph/mock/sourcegraph.pb_mock.go

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -952,15 +952,25 @@ func (s *RepoTreeServer) List(v0 context.Context, v1 *sourcegraph.RepoTreeListOp
952952
var _ sourcegraph.RepoTreeServer = (*RepoTreeServer)(nil)
953953

954954
type SearchClient struct {
955-
Search_ func(ctx context.Context, in *sourcegraph.SearchOptions) (*sourcegraph.SearchResults, error)
956-
Complete_ func(ctx context.Context, in *sourcegraph.RawQuery) (*sourcegraph.Completions, error)
957-
Suggest_ func(ctx context.Context, in *sourcegraph.RawQuery) (*sourcegraph.SuggestionList, error)
955+
Search_ func(ctx context.Context, in *sourcegraph.SearchOptions) (*sourcegraph.SearchResults, error)
956+
SearchTokens_ func(ctx context.Context, in *sourcegraph.TokenSearchOptions) (*sourcegraph.DefList, error)
957+
SearchText_ func(ctx context.Context, in *sourcegraph.TextSearchOptions) (*sourcegraph.VCSSearchResultList, error)
958+
Complete_ func(ctx context.Context, in *sourcegraph.RawQuery) (*sourcegraph.Completions, error)
959+
Suggest_ func(ctx context.Context, in *sourcegraph.RawQuery) (*sourcegraph.SuggestionList, error)
958960
}
959961

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

966+
func (s *SearchClient) SearchTokens(ctx context.Context, in *sourcegraph.TokenSearchOptions, opts ...grpc.CallOption) (*sourcegraph.DefList, error) {
967+
return s.SearchTokens_(ctx, in)
968+
}
969+
970+
func (s *SearchClient) SearchText(ctx context.Context, in *sourcegraph.TextSearchOptions, opts ...grpc.CallOption) (*sourcegraph.VCSSearchResultList, error) {
971+
return s.SearchText_(ctx, in)
972+
}
973+
964974
func (s *SearchClient) Complete(ctx context.Context, in *sourcegraph.RawQuery, opts ...grpc.CallOption) (*sourcegraph.Completions, error) {
965975
return s.Complete_(ctx, in)
966976
}
@@ -972,15 +982,25 @@ func (s *SearchClient) Suggest(ctx context.Context, in *sourcegraph.RawQuery, op
972982
var _ sourcegraph.SearchClient = (*SearchClient)(nil)
973983

974984
type SearchServer struct {
975-
Search_ func(v0 context.Context, v1 *sourcegraph.SearchOptions) (*sourcegraph.SearchResults, error)
976-
Complete_ func(v0 context.Context, v1 *sourcegraph.RawQuery) (*sourcegraph.Completions, error)
977-
Suggest_ func(v0 context.Context, v1 *sourcegraph.RawQuery) (*sourcegraph.SuggestionList, error)
985+
Search_ func(v0 context.Context, v1 *sourcegraph.SearchOptions) (*sourcegraph.SearchResults, error)
986+
SearchTokens_ func(v0 context.Context, v1 *sourcegraph.TokenSearchOptions) (*sourcegraph.DefList, error)
987+
SearchText_ func(v0 context.Context, v1 *sourcegraph.TextSearchOptions) (*sourcegraph.VCSSearchResultList, error)
988+
Complete_ func(v0 context.Context, v1 *sourcegraph.RawQuery) (*sourcegraph.Completions, error)
989+
Suggest_ func(v0 context.Context, v1 *sourcegraph.RawQuery) (*sourcegraph.SuggestionList, error)
978990
}
979991

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

996+
func (s *SearchServer) SearchTokens(v0 context.Context, v1 *sourcegraph.TokenSearchOptions) (*sourcegraph.DefList, error) {
997+
return s.SearchTokens_(v0, v1)
998+
}
999+
1000+
func (s *SearchServer) SearchText(v0 context.Context, v1 *sourcegraph.TextSearchOptions) (*sourcegraph.VCSSearchResultList, error) {
1001+
return s.SearchText_(v0, v1)
1002+
}
1003+
9841004
func (s *SearchServer) Complete(v0 context.Context, v1 *sourcegraph.RawQuery) (*sourcegraph.Completions, error) {
9851005
return s.Complete_(v0, v1)
9861006
}

sourcegraph/sourcegraph.pb.go

Lines changed: 87 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sourcegraph/sourcegraph.proto

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ message ListOptions {
5858
message ListResponse {
5959
// HasMore is true if there are more entries available after the returned page.
6060
bool has_more = 1 [(gogoproto.moretags) = "url:\",omitempty\""];
61+
62+
// Total is the total number of results in the list.
63+
int32 total = 2 [(gogoproto.moretags) = "url:\",omitempty\""];
6164
}
6265

6366
// Discussion stores information about a discussion
@@ -1860,6 +1863,7 @@ message DefsGetOp {
18601863

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

18651869
message DefsListRefsOp {
@@ -2196,8 +2200,20 @@ message RepoTreeListResult {
21962200

21972201
message VCSSearchResultList {
21982202
repeated vcs.SearchResult search_results = 1;
2203+
ListResponse list_response = 2 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
2204+
}
2205+
2206+
message TokenSearchOptions {
2207+
string query = 1 [(gogoproto.moretags) = "url:\"q\" schema:\"q\""];
2208+
ListOptions list_options = 2 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
21992209
}
22002210

2211+
message TextSearchOptions {
2212+
string query = 1 [(gogoproto.moretags) = "url:\"q\" schema:\"q\""];
2213+
ListOptions list_options = 2 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
2214+
}
2215+
2216+
// Deprecated.
22012217
message SearchOptions {
22022218
string query = 1 [(gogoproto.moretags) = "url:\"q\" schema:\"q\""];
22032219
bool defs = 2;
@@ -2207,6 +2223,7 @@ message SearchOptions {
22072223
ListOptions list_options = 6 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
22082224
}
22092225

2226+
// Deprecated.
22102227
message SearchResults {
22112228
repeated Def defs = 1;
22122229
repeated Person people = 2;
@@ -2497,12 +2514,27 @@ service RepoTree {
24972514
// API.
24982515
service Search {
24992516
// Search searches the full index.
2517+
// Deprecated: use one of the more specific search methods below.
25002518
rpc Search(SearchOptions) returns (SearchResults) {
25012519
option (google.api.http) = {
25022520
post: "/search"
25032521
};
25042522
};
25052523

2524+
// SearchTokens searches the index of tokens.
2525+
rpc SearchTokens(TokenSearchOptions) returns (DefList) {
2526+
option (google.api.http) = {
2527+
post: "/search/tokens"
2528+
};
2529+
};
2530+
2531+
// SearchText searches the content of files in the repo tree.
2532+
rpc SearchText(TextSearchOptions) returns (VCSSearchResultList) {
2533+
option (google.api.http) = {
2534+
post: "/search/text"
2535+
};
2536+
};
2537+
25062538
// Complete completes the token at the RawQuery's InsertionPoint.
25072539
rpc Complete(RawQuery) returns (Completions) {
25082540
option (google.api.http) = {

0 commit comments

Comments
 (0)