mirror of https://github.com/dragonflyoss/api.git
				
				
				
			
		
			
				
	
	
		
			275 lines
		
	
	
		
			9.6 KiB
		
	
	
	
		
			Protocol Buffer
		
	
	
	
			
		
		
	
	
			275 lines
		
	
	
		
			9.6 KiB
		
	
	
	
		
			Protocol Buffer
		
	
	
	
/*
 | 
						|
 *     Copyright 2022 The Dragonfly Authors
 | 
						|
 *
 | 
						|
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
						|
 * you may not use this file except in compliance with the License.
 | 
						|
 * You may obtain a copy of the License at
 | 
						|
 *
 | 
						|
 *      http://www.apache.org/licenses/LICENSE-2.0
 | 
						|
 *
 | 
						|
 * Unless required by applicable law or agreed to in writing, software
 | 
						|
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
						|
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
						|
 * See the License for the specific language governing permissions and
 | 
						|
 * limitations under the License.
 | 
						|
 */
 | 
						|
 | 
						|
syntax = "proto3";
 | 
						|
 | 
						|
package scheduler.v2;
 | 
						|
 | 
						|
import "pkg/apis/common/v2/common.proto";
 | 
						|
import "pkg/apis/errordetails/v2/errordetails.proto";
 | 
						|
import "validate/validate.proto";
 | 
						|
import "google/protobuf/empty.proto";
 | 
						|
import "google/protobuf/duration.proto";
 | 
						|
import "google/protobuf/timestamp.proto";
 | 
						|
 | 
						|
option go_package = "d7y.io/api/pkg/apis/scheduler/v2;scheduler";
 | 
						|
 | 
						|
// RegisterPeerRequest represents peer registered request of AnnouncePeerRequest.
 | 
						|
message RegisterPeerRequest {
 | 
						|
  // Download information.
 | 
						|
  common.v2.Download download = 1 [(validate.rules).message.required = true];
 | 
						|
}
 | 
						|
 | 
						|
// DownloadPeerStartedRequest represents peer download started request of AnnouncePeerRequest.
 | 
						|
message DownloadPeerStartedRequest {
 | 
						|
}
 | 
						|
 | 
						|
// DownloadPeerBackToSourceStartedRequest represents peer download back-to-source started request of AnnouncePeerRequest.
 | 
						|
message DownloadPeerBackToSourceStartedRequest {
 | 
						|
  // Download back-to-source reason.
 | 
						|
  string reason = 1 [(validate.rules).string.min_len = 1];
 | 
						|
}
 | 
						|
 | 
						|
// DownloadPeerFinishedRequest represents peer download finished request of AnnouncePeerRequest.
 | 
						|
message DownloadPeerFinishedRequest {
 | 
						|
  // Total content length.
 | 
						|
  int64 content_length = 1 [(validate.rules).int64.gte = 0];
 | 
						|
  // Total piece count.
 | 
						|
  int32 piece_count = 2 [(validate.rules).int32.gte = 0];
 | 
						|
}
 | 
						|
 | 
						|
// DownloadPeerBackToSourceFinishedRequest represents peer download back-to-source finished request of AnnouncePeerRequest.
 | 
						|
message DownloadPeerBackToSourceFinishedRequest {
 | 
						|
  // Total content length.
 | 
						|
  int64 content_length = 1 [(validate.rules).int64.gte = 0];
 | 
						|
  // Total piece count.
 | 
						|
  int32 piece_count = 2 [(validate.rules).int32.gte = 0];
 | 
						|
}
 | 
						|
 | 
						|
// DownloadPieceFinishedRequest represents piece download finished request of AnnouncePeerRequest.
 | 
						|
message DownloadPieceFinishedRequest {
 | 
						|
  // Piece info.
 | 
						|
  common.v2.Piece piece = 1 [(validate.rules).message.required = true];
 | 
						|
}
 | 
						|
 | 
						|
// DownloadPieceBackToSourceFinishedRequest represents piece download back-to-source finished request of AnnouncePeerRequest.
 | 
						|
message DownloadPieceBackToSourceFinishedRequest {
 | 
						|
  // Piece info.
 | 
						|
  common.v2.Piece piece = 1 [(validate.rules).message.required = true];
 | 
						|
}
 | 
						|
 | 
						|
// AnnouncePeerRequest represents request of AnnouncePeer.
 | 
						|
message AnnouncePeerRequest {
 | 
						|
  // Task id.
 | 
						|
  string task_id = 1 [(validate.rules).string.min_len = 1];
 | 
						|
  // Peer id.
 | 
						|
  string peer_id = 2 [(validate.rules).string.min_len = 1];
 | 
						|
 | 
						|
  oneof request {
 | 
						|
    option (validate.required) = true;
 | 
						|
 | 
						|
    RegisterPeerRequest register_peer_request = 3;
 | 
						|
    DownloadPeerStartedRequest download_peer_started_request = 4;
 | 
						|
    DownloadPeerBackToSourceStartedRequest download_peer_back_to_source_started_request = 5;
 | 
						|
    DownloadPeerFinishedRequest download_peer_finished_request = 6;
 | 
						|
    DownloadPeerBackToSourceFinishedRequest download_peer_back_to_source_finished_request = 7;
 | 
						|
    DownloadPieceFinishedRequest download_piece_finished_request = 8;
 | 
						|
    DownloadPieceBackToSourceFinishedRequest download_piece_back_to_source_finished_request = 9;
 | 
						|
  }
 | 
						|
 | 
						|
  oneof errordetails {
 | 
						|
    errordetails.v2.DownloadPeerBackToSourceFailed download_peer_back_to_source_failed = 10;
 | 
						|
    errordetails.v2.DownloadPieceBackToSourceFailed download_piece_back_to_source_failed = 11;
 | 
						|
    errordetails.v2.SyncPiecesFailed sync_pieces_failed = 12;
 | 
						|
    errordetails.v2.DownloadPieceFailed download_piece_failed = 13;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
// TinyTaskResponse represents tiny task response of AnnouncePeerResponse.
 | 
						|
message TinyTaskResponse {
 | 
						|
  bytes data = 1 [(validate.rules).bytes.min_len = 1];
 | 
						|
}
 | 
						|
 | 
						|
// SmallTaskResponse represents small task response of AnnouncePeerResponse.
 | 
						|
message SmallTaskResponse {
 | 
						|
  // Piece info.
 | 
						|
  common.v2.Piece piece = 1 [(validate.rules).message.required = true];
 | 
						|
}
 | 
						|
 | 
						|
// NormalTaskResponse represents normal task response of AnnouncePeerResponse.
 | 
						|
message NormalTaskResponse {
 | 
						|
  // Candidate parents.
 | 
						|
  repeated common.v2.Peer candidate_parents = 1 [(validate.rules).repeated = {min_items: 1}];
 | 
						|
  // Concurrent downloading piece count from the peers.
 | 
						|
  int32 concurrent_piece_count = 2 [(validate.rules).int32.gte = 1];
 | 
						|
}
 | 
						|
 | 
						|
// NeedBackToSourceResponse represents need back-to-source response of AnnouncePeerResponse.
 | 
						|
message NeedBackToSourceResponse {
 | 
						|
  // Download back-to-source reason.
 | 
						|
  string reason = 1 [(validate.rules).string.min_len = 1];
 | 
						|
}
 | 
						|
 | 
						|
// AnnouncePeerResponse represents response of AnnouncePeer.
 | 
						|
message AnnouncePeerResponse {
 | 
						|
  oneof response {
 | 
						|
    option (validate.required) = true;
 | 
						|
 | 
						|
    TinyTaskResponse tiny_task_response = 1;
 | 
						|
    SmallTaskResponse small_task_response = 2;
 | 
						|
    NormalTaskResponse normal_task_response = 3;
 | 
						|
    NeedBackToSourceResponse need_back_to_source_response = 4;
 | 
						|
  }
 | 
						|
 | 
						|
  oneof errordetails {
 | 
						|
    errordetails.v2.SchedulePeerForbidden schedule_peer_forbidden = 5;
 | 
						|
    errordetails.v2.SchedulePeerFailed schedule_peer_failed = 6;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
// StatPeerRequest represents request of StatPeer.
 | 
						|
message StatPeerRequest {
 | 
						|
  // Task id.
 | 
						|
  string task_id = 1 [(validate.rules).string.min_len = 1];
 | 
						|
  // Peer id.
 | 
						|
  string peer_id = 2 [(validate.rules).string.min_len = 1];
 | 
						|
}
 | 
						|
 | 
						|
// TODO exchange peer request definition.
 | 
						|
// ExchangePeerRequest represents request of ExchangePeer.
 | 
						|
message ExchangePeerRequest {
 | 
						|
  // Task id.
 | 
						|
  string task_id = 1 [(validate.rules).string.min_len = 1];
 | 
						|
  // Peer id.
 | 
						|
  string peer_id = 2 [(validate.rules).string.min_len = 1];
 | 
						|
}
 | 
						|
 | 
						|
// TODO exchange peer response definition.
 | 
						|
// ExchangePeerResponse represents response of ExchangePeer.
 | 
						|
message ExchangePeerResponse {
 | 
						|
}
 | 
						|
 | 
						|
// LeavePeerRequest represents request of LeavePeer.
 | 
						|
message LeavePeerRequest {
 | 
						|
  // Task id.
 | 
						|
  string task_id = 1 [(validate.rules).string.min_len = 1];
 | 
						|
  // Peer id.
 | 
						|
  string peer_id = 2 [(validate.rules).string.min_len = 1];
 | 
						|
}
 | 
						|
 | 
						|
// StatTaskRequest represents request of StatTask.
 | 
						|
message StatTaskRequest {
 | 
						|
  // Task id.
 | 
						|
  string id = 1 [(validate.rules).string.min_len = 1];
 | 
						|
}
 | 
						|
 | 
						|
// AnnounceHostRequest represents request of AnnounceHost.
 | 
						|
message AnnounceHostRequest {
 | 
						|
  // Host info.
 | 
						|
  common.v2.Host host = 1 [(validate.rules).message.required = true];
 | 
						|
}
 | 
						|
 | 
						|
// LeaveHostRequest represents request of LeaveHost.
 | 
						|
message LeaveHostRequest{
 | 
						|
  // Host id.
 | 
						|
  string id = 1 [(validate.rules).string.min_len = 1];
 | 
						|
}
 | 
						|
 | 
						|
// Probe information.
 | 
						|
message Probe {
 | 
						|
  // Host metadata.
 | 
						|
  common.v2.Host host = 1 [(validate.rules).message.required = true];
 | 
						|
  // RTT is the round-trip time sent via this pinger.
 | 
						|
  google.protobuf.Duration rtt = 2 [(validate.rules).duration.required = true];
 | 
						|
  // Task update time.
 | 
						|
  google.protobuf.Timestamp updated_at = 3 [(validate.rules).timestamp.required = true];
 | 
						|
}
 | 
						|
 | 
						|
// ProbesOfHost represents probes information of the host.
 | 
						|
message ProbesOfHost {
 | 
						|
  // Host metadata.
 | 
						|
  common.v2.Host host = 1 [(validate.rules).message.required = true];
 | 
						|
  // Probes information.
 | 
						|
  repeated Probe probes = 2 [(validate.rules).repeated = {min_items: 1, ignore_empty: true}];
 | 
						|
}
 | 
						|
 | 
						|
// SyncProbesRequest represents request of SyncProbes.
 | 
						|
message SyncProbesRequest {
 | 
						|
  // Probes information of the host.
 | 
						|
  ProbesOfHost probes_of_host = 1 [(validate.rules).message.required = true];
 | 
						|
}
 | 
						|
 | 
						|
// SyncProbesResponse represents response of SyncProbes.
 | 
						|
message SyncProbesResponse {
 | 
						|
  // Hosts needs to be probed.
 | 
						|
  repeated common.v2.Host hosts = 1 [(validate.rules).repeated = {min_items: 1, ignore_empty: true}];
 | 
						|
  // Probe interval.
 | 
						|
  google.protobuf.Duration probe_interval = 2 [(validate.rules).duration.required = true];
 | 
						|
}
 | 
						|
 | 
						|
// UpdateHostsRequest represents update hosts request of SyncNetworkTopologyRequest.
 | 
						|
message UpdateHostsRequest {
 | 
						|
  // Hosts needs to be updated.
 | 
						|
  repeated ProbesOfHost probes_of_hosts = 1 [(validate.rules).repeated = {min_items: 1}];
 | 
						|
}
 | 
						|
 | 
						|
// DeleteHostsRequest represents delete hosts request of SyncNetworkTopologyRequest.
 | 
						|
message DeleteHostsRequest {
 | 
						|
  // Hosts needs to be deleted.
 | 
						|
  repeated ProbesOfHost probes_of_hosts = 1 [(validate.rules).repeated = {min_items: 1}];
 | 
						|
}
 | 
						|
 | 
						|
// SyncProbesRequest represents request of SyncProbes.
 | 
						|
message SyncNetworkTopologyRequest {
 | 
						|
  oneof request {
 | 
						|
    option (validate.required) = true;
 | 
						|
 | 
						|
    UpdateHostsRequest update_probes_of_hosts_request = 1;
 | 
						|
    DeleteHostsRequest delete_probes_of_hosts_request = 2;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
// Scheduler RPC Service.
 | 
						|
service Scheduler{
 | 
						|
  // AnnouncePeer announces peer to scheduler.
 | 
						|
  rpc AnnouncePeer(stream AnnouncePeerRequest) returns(stream AnnouncePeerResponse);
 | 
						|
 | 
						|
  // Checks information of peer.
 | 
						|
  rpc StatPeer(StatPeerRequest)returns(common.v2.Peer);
 | 
						|
 | 
						|
  // LeavePeer releases peer in scheduler.
 | 
						|
  rpc LeavePeer(LeavePeerRequest)returns(google.protobuf.Empty);
 | 
						|
 | 
						|
  // TODO exchange peer api definition.
 | 
						|
  // ExchangePeer exchanges peer information.
 | 
						|
  rpc ExchangePeer(ExchangePeerRequest)returns(ExchangePeerResponse);
 | 
						|
 | 
						|
  // Checks information of task.
 | 
						|
  rpc StatTask(StatTaskRequest)returns(common.v2.Task);
 | 
						|
 | 
						|
  // AnnounceHost announces host to scheduler.
 | 
						|
  rpc AnnounceHost(AnnounceHostRequest)returns(google.protobuf.Empty);
 | 
						|
 | 
						|
  // LeaveHost releases host in scheduler.
 | 
						|
  rpc LeaveHost(LeaveHostRequest)returns(google.protobuf.Empty);
 | 
						|
 | 
						|
  // SyncProbes sync probes of the host.
 | 
						|
  rpc SyncProbes(stream SyncProbesRequest)returns(stream SyncProbesResponse);
 | 
						|
 | 
						|
  // SyncNetworkTopology sync network topology of the hosts.
 | 
						|
  rpc SyncNetworkTopology(stream SyncNetworkTopologyRequest)returns(google.protobuf.Empty);
 | 
						|
}
 |