Welcome to mirror list, hosted at ThFree Co, Russian Federation.

clocksynced.go « server « service « praefect « internal - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9cb984a846b8fcb81397a57ccba923b9be850a9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package server

import (
	"context"
	"time"

	"gitlab.com/gitlab-org/gitaly/v15/internal/helper"
	"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
)

// ClockSynced checks if system clock is synced.
func (s *Server) ClockSynced(_ context.Context, req *gitalypb.ClockSyncedRequest) (*gitalypb.ClockSyncedResponse, error) {
	driftThreshold := req.DriftThreshold.AsDuration()
	if !req.DriftThreshold.IsValid() || driftThreshold == time.Duration(0) {
		driftThreshold = time.Duration(req.DriftThresholdMillis * int64(time.Millisecond)) //nolint:staticcheck
	}
	synced, err := helper.CheckClockSync(req.NtpHost, driftThreshold)
	if err != nil {
		return nil, err
	}
	return &gitalypb.ClockSyncedResponse{Synced: synced}, nil
}