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

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

import (
	"context"

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

// ClockSynced returns whether the system clock has an acceptable time drift when compared to NTP service.
func (s *server) ClockSynced(_ context.Context, req *gitalypb.ClockSyncedRequest) (*gitalypb.ClockSyncedResponse, error) {
	if err := req.DriftThreshold.CheckValid(); err != nil {
		return nil, structerr.NewInvalidArgument("%w", err)
	}
	synced, err := helper.CheckClockSync(req.NtpHost, req.DriftThreshold.AsDuration())
	if err != nil {
		return nil, err
	}
	return &gitalypb.ClockSyncedResponse{Synced: synced}, nil
}