1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package info
import (
"context"
"errors"
"fmt"
"gitlab.com/gitlab-org/gitaly/internal/helper"
"gitlab.com/gitlab-org/gitaly/internal/praefect/datastore"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
func (s *Server) SetReplicationFactor(ctx context.Context, req *gitalypb.SetReplicationFactorRequest) (*gitalypb.SetReplicationFactorResponse, error) {
resp, err := s.setReplicationFactor(ctx, req)
if err != nil {
var invalidArg datastore.InvalidArgumentError
if errors.As(err, &invalidArg) {
return nil, helper.ErrInvalidArgument(err)
}
return nil, helper.ErrInternal(err)
}
return resp, nil
}
func (s *Server) setReplicationFactor(ctx context.Context, req *gitalypb.SetReplicationFactorRequest) (*gitalypb.SetReplicationFactorResponse, error) {
storages, err := s.assignmentStore.SetReplicationFactor(ctx, req.VirtualStorage, req.RelativePath, int(req.ReplicationFactor))
if err != nil {
return nil, fmt.Errorf("set replication factor: %w", err)
}
return &gitalypb.SetReplicationFactorResponse{Storages: storages}, nil
}
|