diff options
author | John Cai <jcai@gitlab.com> | 2020-06-03 01:41:35 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2020-06-03 01:41:35 +0300 |
commit | 57490bbd9b948aa50449e1c8f572691ebd6f10aa (patch) | |
tree | 4c20b3878a0aeacba799afebde5db8b5c7523e1b | |
parent | 308a1563e29d11f057f4236e5b84ed8a7d6b00bd (diff) | |
parent | 0d46bf3cad30fca17906bef33e8e2effe91f0327 (diff) |
Merge branch 'pks-lint-fixes' into 'master'
Linting fixes
See merge request gitlab-org/gitaly!2238
-rw-r--r-- | internal/praefect/metadata/server.go | 2 | ||||
-rw-r--r-- | internal/praefect/server_test.go | 1 | ||||
-rw-r--r-- | internal/praefect/transactions/manager.go | 28 | ||||
-rw-r--r-- | internal/service/hook/access.go | 2 |
4 files changed, 17 insertions, 16 deletions
diff --git a/internal/praefect/metadata/server.go b/internal/praefect/metadata/server.go index 7b1adba6c..0de0d7a7a 100644 --- a/internal/praefect/metadata/server.go +++ b/internal/praefect/metadata/server.go @@ -27,7 +27,7 @@ const ( var ( // ErrPraefectServerNotFound indicates the Praefect server metadata // could not be found - ErrPraefectServerNotFound = errors.New("Praefect server info not found") + ErrPraefectServerNotFound = errors.New("metadata for Praefect server not found") ) // PraefectServer stores parameters required to connect to a Praefect server diff --git a/internal/praefect/server_test.go b/internal/praefect/server_test.go index c4dd3be1d..9f59145ec 100644 --- a/internal/praefect/server_test.go +++ b/internal/praefect/server_test.go @@ -376,6 +376,7 @@ func TestWarnDuplicateAddrs(t *testing.T) { withLogger: logrus.NewEntry(tLogger), withNodeMgr: nullNodeMgr{}, // to suppress node address issues }) + defer cleanup() for _, entry := range hook.Entries { require.NotContains(t, entry.Message, "more than one backend node") diff --git a/internal/praefect/transactions/manager.go b/internal/praefect/transactions/manager.go index b5059c01f..37c54e459 100644 --- a/internal/praefect/transactions/manager.go +++ b/internal/praefect/transactions/manager.go @@ -22,24 +22,24 @@ var ErrNotFound = errors.New("transaction not found") // for Praefect to handle transactions directly instead of having to reach out // to reference transaction RPCs. type Manager struct { - txIdGenerator TransactionIdGenerator + txIDGenerator TransactionIDGenerator lock sync.Mutex transactions map[uint64]*transaction counterMetric *prometheus.CounterVec delayMetric metrics.HistogramVec } -// TransactionIdGenerator is an interface for types that can generate transaction IDs. -type TransactionIdGenerator interface { - // Id generates a new transaction identifier - Id() uint64 +// TransactionIDGenerator is an interface for types that can generate transaction IDs. +type TransactionIDGenerator interface { + // ID generates a new transaction identifier + ID() uint64 } -type transactionIdGenerator struct { +type transactionIDGenerator struct { rand *rand.Rand } -func newTransactionIdGenerator() *transactionIdGenerator { +func newTransactionIDGenerator() *transactionIDGenerator { var seed [8]byte // Ignore any errors. In case we weren't able to generate a seed, the @@ -47,12 +47,12 @@ func newTransactionIdGenerator() *transactionIdGenerator { cryptorand.Read(seed[:]) source := rand.NewSource(int64(binary.LittleEndian.Uint64(seed[:]))) - return &transactionIdGenerator{ + return &transactionIDGenerator{ rand: rand.New(source), } } -func (t *transactionIdGenerator) Id() uint64 { +func (t *transactionIDGenerator) ID() uint64 { return rand.Uint64() } @@ -73,17 +73,17 @@ func WithDelayMetric(delayMetric metrics.HistogramVec) ManagerOpt { } } -// WithTransactionIdGenerator is an option to set the transaction ID generator -func WithTransactionIdGenerator(generator TransactionIdGenerator) ManagerOpt { +// WithTransactionIDGenerator is an option to set the transaction ID generator +func WithTransactionIDGenerator(generator TransactionIDGenerator) ManagerOpt { return func(mgr *Manager) { - mgr.txIdGenerator = generator + mgr.txIDGenerator = generator } } // NewManager creates a new transactions Manager. func NewManager(opts ...ManagerOpt) *Manager { mgr := &Manager{ - txIdGenerator: newTransactionIdGenerator(), + txIDGenerator: newTransactionIDGenerator(), transactions: make(map[uint64]*transaction), counterMetric: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"action"}), delayMetric: prometheus.NewHistogramVec(prometheus.HistogramOpts{}, []string{"action"}), @@ -115,7 +115,7 @@ func (mgr *Manager) RegisterTransaction(ctx context.Context, nodes []string) (ui // that reset on restart of Praefect would be suboptimal, as the chance // for collisions is a lot higher in case Praefect restarts when Gitaly // nodes still have in-flight transactions. - transactionID := mgr.txIdGenerator.Id() + transactionID := mgr.txIDGenerator.ID() transaction, err := newTransaction(nodes) if err != nil { diff --git a/internal/service/hook/access.go b/internal/service/hook/access.go index dbb5db2ec..1cbfdcbcd 100644 --- a/internal/service/hook/access.go +++ b/internal/service/hook/access.go @@ -208,7 +208,7 @@ func (a *AllowedRequest) parseAndSetGLID(glID string) error { } if !glIDRegex.MatchString(value) { - return fmt.Errorf("gl_id='%s' is invalid!", glID) + return fmt.Errorf("gl_id='%s' is invalid", glID) } return nil |