Skip to content
Snippets Groups Projects

Full MVC of gitlab-zoekt-indexer

Merged Dylan Griffith requested to merge add-new-api-paths into main
All threads resolved!
Compare and Show latest version
3 files
+ 18
16
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -18,6 +18,7 @@ import (
@@ -18,6 +18,7 @@ import (
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/client_golang/prometheus/promhttp"
 
"gitlab.com/gitlab-org/search-team/gitlab-zoekt-indexer/correlation"
"gitlab.com/gitlab-org/search-team/gitlab-zoekt-indexer/indexer"
"gitlab.com/gitlab-org/search-team/gitlab-zoekt-indexer/indexer"
)
)
@@ -46,7 +47,15 @@ type indexRequest struct {
@@ -46,7 +47,15 @@ type indexRequest struct {
FileSizeLimit int
FileSizeLimit int
}
}
func (s *indexServer) indexRepository(req indexRequest, ctx context.Context) error {
func (req indexRequest) indexRepository(ctx context.Context, indexDir string) error {
 
if req.GitalyConnectionInfo == nil {
 
return errors.New("gitalyConnectionInfo is not set")
 
}
 
 
if req.FileSizeLimit == 0 {
 
return errors.New("fileSizeLimit is not set")
 
}
 
timeout, err := time.ParseDuration(req.Timeout)
timeout, err := time.ParseDuration(req.Timeout)
if err != nil {
if err != nil {
return fmt.Errorf("failed to parse Timeout: %v with error %v", req.Timeout, err)
return fmt.Errorf("failed to parse Timeout: %v with error %v", req.Timeout, err)
@@ -56,9 +65,9 @@ func (s *indexServer) indexRepository(req indexRequest, ctx context.Context) err
@@ -56,9 +65,9 @@ func (s *indexServer) indexRepository(req indexRequest, ctx context.Context) err
defer cancel()
defer cancel()
idx := &indexer.Indexer{
idx := &indexer.Indexer{
IndexDir: s.indexDir,
IndexDir: indexDir,
ProjectID: req.RepoID,
ProjectID: req.RepoID,
CorrelationID: getCorrelationID(ctx),
CorrelationID: correlation.GetCorrelationID(ctx),
GitalyAddress: req.GitalyConnectionInfo.Address,
GitalyAddress: req.GitalyConnectionInfo.Address,
GitalyStorageName: req.GitalyConnectionInfo.Storage,
GitalyStorageName: req.GitalyConnectionInfo.Storage,
GitalyRelativePath: req.GitalyConnectionInfo.Path,
GitalyRelativePath: req.GitalyConnectionInfo.Path,
@@ -148,14 +157,6 @@ func (s *indexServer) handleIndex() http.HandlerFunc {
@@ -148,14 +157,6 @@ func (s *indexServer) handleIndex() http.HandlerFunc {
return req, errors.New("json parser error")
return req, errors.New("json parser error")
}
}
if req.GitalyConnectionInfo == nil {
return req, errors.New("gitalyConnectionInfo Error")
}
if req.FileSizeLimit == 0 {
return req, errors.New("fileSizeLimit is not set")
}
return req, nil
return req, nil
}
}
@@ -166,7 +167,7 @@ func (s *indexServer) handleIndex() http.HandlerFunc {
@@ -166,7 +167,7 @@ func (s *indexServer) handleIndex() http.HandlerFunc {
return
return
}
}
err = s.indexRepository(req, r.Context())
err = req.indexRepository(r.Context(), s.indexDir)
if err != nil {
if err != nil {
s.respondWithError(w, r, route, err)
s.respondWithError(w, r, route, err)
return
return
Loading