diff options
author | Ævar Arnfjörð Bjarmason <avar@gitlab.com> | 2020-09-16 16:54:16 +0300 |
---|---|---|
committer | Ævar Arnfjörð Bjarmason <avar@gitlab.com> | 2020-09-16 16:54:16 +0300 |
commit | c9434931eb970b012860d7812274cd16eae50b16 (patch) | |
tree | ef9c0ff9ef7f073e947b490646a48b8ba50aa26e | |
parent | ab2f2386ab69575cd0a58f7279be707a17d7a6c8 (diff) | |
parent | 90a0fe156f60e273fa0adc761b30acfbaaff5fe6 (diff) |
Merge branch 'ps-diff-uses-locator' into 'master'
Introduce Locator abstraction to diff service
See merge request gitlab-org/gitaly!2559
-rw-r--r-- | changelogs/unreleased/ps-diff-uses-locator.yml | 5 | ||||
-rw-r--r-- | internal/gitaly/service/diff/numstat.go | 7 | ||||
-rw-r--r-- | internal/gitaly/service/diff/server.go | 5 | ||||
-rw-r--r-- | internal/gitaly/service/diff/testhelper_test.go | 3 | ||||
-rw-r--r-- | internal/gitaly/service/register.go | 2 |
5 files changed, 15 insertions, 7 deletions
diff --git a/changelogs/unreleased/ps-diff-uses-locator.yml b/changelogs/unreleased/ps-diff-uses-locator.yml new file mode 100644 index 000000000..6758150d2 --- /dev/null +++ b/changelogs/unreleased/ps-diff-uses-locator.yml @@ -0,0 +1,5 @@ +--- +title: Introduce Locator abstraction to diff service +merge_request: 2559 +author: +type: changed diff --git a/internal/gitaly/service/diff/numstat.go b/internal/gitaly/service/diff/numstat.go index 5a7d66d5f..ec892a681 100644 --- a/internal/gitaly/service/diff/numstat.go +++ b/internal/gitaly/service/diff/numstat.go @@ -5,7 +5,6 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/gitaly/diff" - "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -16,7 +15,7 @@ var ( ) func (s *server) DiffStats(in *gitalypb.DiffStatsRequest, stream gitalypb.DiffService_DiffStatsServer) error { - if err := validateDiffStatsRequestParams(in); err != nil { + if err := s.validateDiffStatsRequestParams(in); err != nil { return err } @@ -83,9 +82,9 @@ func sendStats(batch []*gitalypb.DiffStats, stream gitalypb.DiffService_DiffStat return nil } -func validateDiffStatsRequestParams(in *gitalypb.DiffStatsRequest) error { +func (s *server) validateDiffStatsRequestParams(in *gitalypb.DiffStatsRequest) error { repo := in.GetRepository() - if _, err := helper.GetRepoPath(repo); err != nil { + if _, err := s.locator.GetRepoPath(repo); err != nil { return err } diff --git a/internal/gitaly/service/diff/server.go b/internal/gitaly/service/diff/server.go index 22520a33f..24e0e56bd 100644 --- a/internal/gitaly/service/diff/server.go +++ b/internal/gitaly/service/diff/server.go @@ -1,6 +1,7 @@ package diff import ( + "gitlab.com/gitlab-org/gitaly/internal/storage" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" ) @@ -8,12 +9,14 @@ const msgSizeThreshold = 5 * 1024 type server struct { MsgSizeThreshold int + locator storage.Locator gitalypb.UnimplementedDiffServiceServer } // NewServer creates a new instance of a gRPC DiffServer -func NewServer() gitalypb.DiffServiceServer { +func NewServer(locator storage.Locator) gitalypb.DiffServiceServer { return &server{ MsgSizeThreshold: msgSizeThreshold, + locator: locator, } } diff --git a/internal/gitaly/service/diff/testhelper_test.go b/internal/gitaly/service/diff/testhelper_test.go index d3d32efd2..a701953f6 100644 --- a/internal/gitaly/service/diff/testhelper_test.go +++ b/internal/gitaly/service/diff/testhelper_test.go @@ -5,6 +5,7 @@ import ( "os" "testing" + "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc" @@ -31,7 +32,7 @@ func runDiffServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - gitalypb.RegisterDiffServiceServer(server, NewServer()) + gitalypb.RegisterDiffServiceServer(server, NewServer(config.NewLocator(config.Config))) reflection.Register(server) go server.Serve(listener) diff --git a/internal/gitaly/service/register.go b/internal/gitaly/service/register.go index cd9de4afa..c579c0f22 100644 --- a/internal/gitaly/service/register.go +++ b/internal/gitaly/service/register.go @@ -71,7 +71,7 @@ func RegisterAll(grpcServer *grpc.Server, cfg config.Cfg, rubyServer *rubyserver gitalypb.RegisterBlobServiceServer(grpcServer, blob.NewServer(rubyServer)) gitalypb.RegisterCleanupServiceServer(grpcServer, cleanup.NewServer()) gitalypb.RegisterCommitServiceServer(grpcServer, commit.NewServer(locator)) - gitalypb.RegisterDiffServiceServer(grpcServer, diff.NewServer()) + gitalypb.RegisterDiffServiceServer(grpcServer, diff.NewServer(locator)) gitalypb.RegisterNamespaceServiceServer(grpcServer, namespace.NewServer()) gitalypb.RegisterOperationServiceServer(grpcServer, operations.NewServer(cfg, rubyServer, hookManager, locator)) gitalypb.RegisterRefServiceServer(grpcServer, ref.NewServer()) |