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: 0f370496313366758a720cc2442d2e6765ff5ca0 (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/v15/structerr"

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

// 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
}