Skip to content

Commit

Permalink
feat: add GetCommits endpoint for efficient multi-commits fetching (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
marcsanmi authored Aug 29, 2024
1 parent b2ce6a2 commit 45c58c3
Show file tree
Hide file tree
Showing 13 changed files with 1,598 additions and 239 deletions.
353 changes: 303 additions & 50 deletions api/gen/proto/go/vcs/v1/vcs.pb.go

Large diffs are not rendered by default.

910 changes: 875 additions & 35 deletions api/gen/proto/go/vcs/v1/vcs_vtproto.pb.go

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions api/gen/proto/go/vcs/v1/vcsv1connect/vcs.connect.go

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

5 changes: 5 additions & 0 deletions api/gen/proto/go/vcs/v1/vcsv1connect/vcs.connect.mux.go

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

37 changes: 37 additions & 0 deletions api/openapiv2/gen/phlare.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,31 @@
}
}
},
"v1CommitInfo": {
"type": "object",
"properties": {
"message": {
"type": "string",
"title": "the commit message"
},
"author": {
"$ref": "#/definitions/v1CommitAuthor",
"title": "the commit author login"
},
"date": {
"type": "string",
"title": "the commit date"
},
"sha": {
"type": "string",
"title": "the commit sha"
},
"URL": {
"type": "string",
"title": "the full URL to the commit"
}
}
},
"v1CompactionJob": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -977,6 +1002,18 @@
}
}
},
"v1GetCommitsResponse": {
"type": "object",
"properties": {
"commits": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/v1CommitInfo"
}
}
}
},
"v1GetCompactionResponse": {
"type": "object",
"properties": {
Expand Down
24 changes: 24 additions & 0 deletions api/vcs/v1/vcs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ service VCSService {
rpc GithubRefresh(GithubRefreshRequest) returns (GithubRefreshResponse) {}
rpc GetFile(GetFileRequest) returns (GetFileResponse) {}
rpc GetCommit(GetCommitRequest) returns (GetCommitResponse) {}
rpc GetCommits(GetCommitsRequest) returns (GetCommitsResponse) {}
}
message GithubAppRequest {}

Expand Down Expand Up @@ -71,3 +72,26 @@ message CommitAuthor {
// the author avatar URL
string avatarURL = 2;
}

message CommitInfo {
// the commit message
string message = 1;
// the commit author login
CommitAuthor author = 2;
// the commit date
string date = 3;
// the commit sha
string sha = 4;
// the full URL to the commit
string URL = 5;
}

// New messages for the GetCommits method
message GetCommitsRequest {
string repository_url = 1;
repeated string refs = 2;
}

message GetCommitsResponse {
repeated CommitInfo commits = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,6 @@ lifecycler:
# values:
#
# Secure Ciphers:
# - TLS_RSA_WITH_AES_128_CBC_SHA
# - TLS_RSA_WITH_AES_256_CBC_SHA
# - TLS_RSA_WITH_AES_128_GCM_SHA256
# - TLS_RSA_WITH_AES_256_GCM_SHA384
# - TLS_AES_128_GCM_SHA256
# - TLS_AES_256_GCM_SHA384
# - TLS_CHACHA20_POLY1305_SHA256
Expand All @@ -654,7 +650,11 @@ lifecycler:
# Insecure Ciphers:
# - TLS_RSA_WITH_RC4_128_SHA
# - TLS_RSA_WITH_3DES_EDE_CBC_SHA
# - TLS_RSA_WITH_AES_128_CBC_SHA
# - TLS_RSA_WITH_AES_256_CBC_SHA
# - TLS_RSA_WITH_AES_128_CBC_SHA256
# - TLS_RSA_WITH_AES_128_GCM_SHA256
# - TLS_RSA_WITH_AES_256_GCM_SHA384
# - TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
# - TLS_ECDHE_RSA_WITH_RC4_128_SHA
# - TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
Expand Down Expand Up @@ -990,10 +990,6 @@ sharding_ring:
# values:
#
# Secure Ciphers:
# - TLS_RSA_WITH_AES_128_CBC_SHA
# - TLS_RSA_WITH_AES_256_CBC_SHA
# - TLS_RSA_WITH_AES_128_GCM_SHA256
# - TLS_RSA_WITH_AES_256_GCM_SHA384
# - TLS_AES_128_GCM_SHA256
# - TLS_AES_256_GCM_SHA384
# - TLS_CHACHA20_POLY1305_SHA256
Expand All @@ -1011,7 +1007,11 @@ sharding_ring:
# Insecure Ciphers:
# - TLS_RSA_WITH_RC4_128_SHA
# - TLS_RSA_WITH_3DES_EDE_CBC_SHA
# - TLS_RSA_WITH_AES_128_CBC_SHA
# - TLS_RSA_WITH_AES_256_CBC_SHA
# - TLS_RSA_WITH_AES_128_CBC_SHA256
# - TLS_RSA_WITH_AES_128_GCM_SHA256
# - TLS_RSA_WITH_AES_256_GCM_SHA384
# - TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
# - TLS_ECDHE_RSA_WITH_RC4_128_SHA
# - TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
Expand Down Expand Up @@ -1339,10 +1339,6 @@ sharding_ring:
# values:
#
# Secure Ciphers:
# - TLS_RSA_WITH_AES_128_CBC_SHA
# - TLS_RSA_WITH_AES_256_CBC_SHA
# - TLS_RSA_WITH_AES_128_GCM_SHA256
# - TLS_RSA_WITH_AES_256_GCM_SHA384
# - TLS_AES_128_GCM_SHA256
# - TLS_AES_256_GCM_SHA384
# - TLS_CHACHA20_POLY1305_SHA256
Expand All @@ -1360,7 +1356,11 @@ sharding_ring:
# Insecure Ciphers:
# - TLS_RSA_WITH_RC4_128_SHA
# - TLS_RSA_WITH_3DES_EDE_CBC_SHA
# - TLS_RSA_WITH_AES_128_CBC_SHA
# - TLS_RSA_WITH_AES_256_CBC_SHA
# - TLS_RSA_WITH_AES_128_CBC_SHA256
# - TLS_RSA_WITH_AES_128_GCM_SHA256
# - TLS_RSA_WITH_AES_256_GCM_SHA384
# - TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
# - TLS_ECDHE_RSA_WITH_RC4_128_SHA
# - TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
Expand Down Expand Up @@ -1547,10 +1547,6 @@ backoff_config:
# Override the default cipher suite list (separated by commas). Allowed values:
#
# Secure Ciphers:
# - TLS_RSA_WITH_AES_128_CBC_SHA
# - TLS_RSA_WITH_AES_256_CBC_SHA
# - TLS_RSA_WITH_AES_128_GCM_SHA256
# - TLS_RSA_WITH_AES_256_GCM_SHA384
# - TLS_AES_128_GCM_SHA256
# - TLS_AES_256_GCM_SHA384
# - TLS_CHACHA20_POLY1305_SHA256
Expand All @@ -1568,7 +1564,11 @@ backoff_config:
# Insecure Ciphers:
# - TLS_RSA_WITH_RC4_128_SHA
# - TLS_RSA_WITH_3DES_EDE_CBC_SHA
# - TLS_RSA_WITH_AES_128_CBC_SHA
# - TLS_RSA_WITH_AES_256_CBC_SHA
# - TLS_RSA_WITH_AES_128_CBC_SHA256
# - TLS_RSA_WITH_AES_128_GCM_SHA256
# - TLS_RSA_WITH_AES_256_GCM_SHA384
# - TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
# - TLS_ECDHE_RSA_WITH_RC4_128_SHA
# - TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
Expand Down Expand Up @@ -1760,10 +1760,6 @@ The `memberlist` block configures the Gossip memberlist.
# Override the default cipher suite list (separated by commas). Allowed values:
#
# Secure Ciphers:
# - TLS_RSA_WITH_AES_128_CBC_SHA
# - TLS_RSA_WITH_AES_256_CBC_SHA
# - TLS_RSA_WITH_AES_128_GCM_SHA256
# - TLS_RSA_WITH_AES_256_GCM_SHA384
# - TLS_AES_128_GCM_SHA256
# - TLS_AES_256_GCM_SHA384
# - TLS_CHACHA20_POLY1305_SHA256
Expand All @@ -1781,7 +1777,11 @@ The `memberlist` block configures the Gossip memberlist.
# Insecure Ciphers:
# - TLS_RSA_WITH_RC4_128_SHA
# - TLS_RSA_WITH_3DES_EDE_CBC_SHA
# - TLS_RSA_WITH_AES_128_CBC_SHA
# - TLS_RSA_WITH_AES_256_CBC_SHA
# - TLS_RSA_WITH_AES_128_CBC_SHA256
# - TLS_RSA_WITH_AES_128_GCM_SHA256
# - TLS_RSA_WITH_AES_256_GCM_SHA384
# - TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
# - TLS_ECDHE_RSA_WITH_RC4_128_SHA
# - TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
Expand Down
4 changes: 4 additions & 0 deletions pkg/frontend/frontend_vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ func (f *Frontend) GetFile(ctx context.Context, req *connect.Request[vcsv1.GetFi
func (f *Frontend) GetCommit(ctx context.Context, req *connect.Request[vcsv1.GetCommitRequest]) (*connect.Response[vcsv1.GetCommitResponse], error) {
return connectgrpc.RoundTripUnary[vcsv1.GetCommitRequest, vcsv1.GetCommitResponse](ctx, f, req)
}

func (f *Frontend) GetCommits(ctx context.Context, req *connect.Request[vcsv1.GetCommitsRequest]) (*connect.Response[vcsv1.GetCommitsResponse], error) {
return connectgrpc.RoundTripUnary[vcsv1.GetCommitsRequest, vcsv1.GetCommitsResponse](ctx, f, req)
}
4 changes: 2 additions & 2 deletions pkg/querier/vcs/client/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type githubClient struct {
client *github.Client
}

func (gh *githubClient) GetCommit(ctx context.Context, owner, repo, ref string) (*vcsv1.GetCommitResponse, error) {
func (gh *githubClient) GetCommit(ctx context.Context, owner, repo, ref string) (*vcsv1.CommitInfo, error) {
commit, _, err := gh.client.Repositories.GetCommit(ctx, owner, repo, ref, nil)
if err != nil {
var githubErr *github.ErrorResponse
Expand All @@ -37,7 +37,7 @@ func (gh *githubClient) GetCommit(ctx context.Context, owner, repo, ref string)
return nil, err
}

return &vcsv1.GetCommitResponse{
return &vcsv1.CommitInfo{
Sha: toString(commit.SHA),
Message: toString(commit.Commit.Message),
Author: &vcsv1.CommitAuthor{
Expand Down
Loading

0 comments on commit 45c58c3

Please sign in to comment.