syntax = "proto3";

package gitaly;

option go_package = "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb";

import "lint.proto";

service ServerService {
  option (intercepted) = true;

  rpc ServerInfo(ServerInfoRequest) returns (ServerInfoResponse);
  rpc DiskStatistics(DiskStatisticsRequest) returns (DiskStatisticsResponse);
  // ClockSynced checks if machine clock is synced
  // (the offset is less that the one passed in the request).
  rpc ClockSynced(ClockSyncedRequest) returns (ClockSyncedResponse) {}
}

message ServerInfoRequest {}

message ServerInfoResponse {
  message StorageStatus {
    string storage_name = 1;
    bool readable = 2;
    bool writeable = 3;
    string fs_type = 4;
    string filesystem_id = 5;
    uint32 replication_factor = 6;
  }

  string server_version = 1;
  string git_version = 2;
  repeated StorageStatus storage_statuses = 3;
}

message DiskStatisticsRequest {}

message DiskStatisticsResponse {
  message StorageStatus {
// When both available and used fields are equal 0 that means that
// Gitaly was unable to determine storage stats.
    string storage_name = 1;
    int64 available = 2;
    int64 used = 3;
  }

  repeated StorageStatus storage_statuses = 1;
}

message ClockSyncedRequest {
  // ntp_host is a URL to the external NTP service that should be used for clock sync check.
  // Default is ntp.pool.org
  string ntp_host = 1;
  // drift_threshold_millis is an allowed drift from the NTP service in milliseconds.
  int64 drift_threshold_millis = 2;
}

message ClockSyncedResponse {
  // synced is set to true if system clock has an affordable drift compared to NTP service.
  bool synced = 1;
}
