Protocol Buffer · 4425 bytes Raw Blame History
1 syntax = "proto3";
2
3 package zephyrfs.coordinator;
4
5 option go_package = "github.com/ZephyrFS/zephyrfs-proto/gen/go/coordinator";
6
7 // Coordinator service for peer discovery and metadata management
8 service CoordinatorService {
9 // Node registration and discovery
10 rpc RegisterNode(RegisterNodeRequest) returns (RegisterNodeResponse);
11 rpc UnregisterNode(UnregisterNodeRequest) returns (UnregisterNodeResponse);
12 rpc GetActiveNodes(GetActiveNodesRequest) returns (GetActiveNodesResponse);
13 rpc NodeHeartbeat(NodeHeartbeatRequest) returns (NodeHeartbeatResponse);
14
15 // File and chunk coordination
16 rpc RegisterFile(RegisterFileRequest) returns (RegisterFileResponse);
17 rpc GetFileInfo(GetFileInfoRequest) returns (GetFileInfoResponse);
18 rpc UpdateChunkLocations(UpdateChunkLocationsRequest) returns (UpdateChunkLocationsResponse);
19 rpc FindChunkLocations(FindChunkLocationsRequest) returns (FindChunkLocationsResponse);
20
21 // Network health and monitoring
22 rpc GetNetworkStatus(GetNetworkStatusRequest) returns (GetNetworkStatusResponse);
23 }
24
25 // Node management messages
26 message RegisterNodeRequest {
27 string node_id = 1;
28 repeated string addresses = 2;
29 int64 storage_capacity = 3;
30 map<string, string> capabilities = 4;
31 }
32
33 message RegisterNodeResponse {
34 bool success = 1;
35 string message = 2;
36 string assigned_node_id = 3;
37 repeated string bootstrap_peers = 4;
38 }
39
40 message UnregisterNodeRequest {
41 string node_id = 1;
42 string reason = 2;
43 }
44
45 message UnregisterNodeResponse {
46 bool success = 1;
47 string message = 2;
48 }
49
50 message GetActiveNodesRequest {
51 int32 limit = 1;
52 repeated string exclude_nodes = 2;
53 }
54
55 message GetActiveNodesResponse {
56 repeated NodeStatus nodes = 1;
57 int32 total_nodes = 2;
58 }
59
60 message NodeHeartbeatRequest {
61 string node_id = 1;
62 NodeStats stats = 2;
63 }
64
65 message NodeHeartbeatResponse {
66 bool success = 1;
67 string message = 2;
68 repeated string tasks = 3;
69 }
70
71 // File coordination messages
72 message RegisterFileRequest {
73 string file_id = 1;
74 string file_name = 2;
75 int64 file_size = 3;
76 string file_hash = 4;
77 repeated ChunkMetadata chunks = 5;
78 string owner_node_id = 6;
79 }
80
81 message RegisterFileResponse {
82 bool success = 1;
83 string message = 2;
84 repeated ChunkPlacement chunk_placements = 3;
85 }
86
87 message GetFileInfoRequest {
88 string file_id = 1;
89 }
90
91 message GetFileInfoResponse {
92 bool success = 1;
93 string message = 2;
94 FileRecord file_info = 3;
95 }
96
97 message UpdateChunkLocationsRequest {
98 string chunk_id = 1;
99 repeated string node_ids = 2;
100 string operation = 3; // "add" or "remove"
101 }
102
103 message UpdateChunkLocationsResponse {
104 bool success = 1;
105 string message = 2;
106 }
107
108 message FindChunkLocationsRequest {
109 string chunk_id = 1;
110 int32 preferred_count = 2;
111 }
112
113 message FindChunkLocationsResponse {
114 bool success = 1;
115 string message = 2;
116 repeated string node_ids = 3;
117 repeated string node_addresses = 4;
118 }
119
120 // Network monitoring messages
121 message GetNetworkStatusRequest {}
122
123 message GetNetworkStatusResponse {
124 NetworkStats network_stats = 1;
125 repeated NodeStatus active_nodes = 2;
126 int64 timestamp = 3;
127 }
128
129 // Data structures
130 message NodeStatus {
131 string node_id = 1;
132 repeated string addresses = 2;
133 NodeStats stats = 3;
134 int64 last_heartbeat = 4;
135 string status = 5; // "active", "inactive", "maintenance"
136 }
137
138 message NodeStats {
139 int64 storage_used = 1;
140 int64 storage_available = 2;
141 int64 chunks_stored = 3;
142 int64 bandwidth_up = 4;
143 int64 bandwidth_down = 5;
144 double cpu_usage = 6;
145 double memory_usage = 7;
146 int64 uptime_seconds = 8;
147 }
148
149 message ChunkMetadata {
150 string chunk_id = 1;
151 string hash = 2;
152 int64 size = 3;
153 int32 index = 4;
154 }
155
156 message ChunkPlacement {
157 string chunk_id = 1;
158 repeated string target_nodes = 2;
159 int32 replication_factor = 3;
160 }
161
162 message FileRecord {
163 string file_id = 1;
164 string file_name = 2;
165 int64 file_size = 3;
166 string file_hash = 4;
167 repeated ChunkRecord chunks = 5;
168 string owner_node_id = 6;
169 int64 created_at = 7;
170 int64 last_accessed = 8;
171 }
172
173 message ChunkRecord {
174 string chunk_id = 1;
175 string hash = 2;
176 int64 size = 3;
177 int32 index = 4;
178 repeated string stored_at_nodes = 5;
179 int32 replication_count = 6;
180 }
181
182 message NetworkStats {
183 int32 total_nodes = 1;
184 int32 active_nodes = 2;
185 int64 total_storage_capacity = 3;
186 int64 total_storage_used = 4;
187 int64 total_files = 5;
188 int64 total_chunks = 6;
189 double average_node_uptime = 7;
190 int64 network_uptime_seconds = 8;
191 }