| 1 |
syntax = "proto3"; |
| 2 |
|
| 3 |
package zephyrfs.node; |
| 4 |
|
| 5 |
option go_package = "github.com/ZephyrFS/zephyrfs-proto/gen/go/node"; |
| 6 |
|
| 7 |
// Core message types for P2P communication |
| 8 |
service NodeService { |
| 9 |
// Health check for node status |
| 10 |
rpc HealthCheck(HealthCheckRequest) returns (HealthCheckResponse); |
| 11 |
|
| 12 |
// Peer discovery and connection management |
| 13 |
rpc RegisterPeer(RegisterPeerRequest) returns (RegisterPeerResponse); |
| 14 |
rpc GetPeers(GetPeersRequest) returns (GetPeersResponse); |
| 15 |
|
| 16 |
// Chunk storage operations |
| 17 |
rpc StoreChunk(StoreChunkRequest) returns (StoreChunkResponse); |
| 18 |
rpc RetrieveChunk(RetrieveChunkRequest) returns (RetrieveChunkResponse); |
| 19 |
rpc DeleteChunk(DeleteChunkRequest) returns (DeleteChunkResponse); |
| 20 |
|
| 21 |
// File metadata operations |
| 22 |
rpc StoreMetadata(StoreMetadataRequest) returns (StoreMetadataResponse); |
| 23 |
rpc RetrieveMetadata(RetrieveMetadataRequest) returns (RetrieveMetadataResponse); |
| 24 |
} |
| 25 |
|
| 26 |
// Health check messages |
| 27 |
message HealthCheckRequest {} |
| 28 |
|
| 29 |
message HealthCheckResponse { |
| 30 |
string status = 1; |
| 31 |
int64 timestamp = 2; |
| 32 |
NodeInfo node_info = 3; |
| 33 |
} |
| 34 |
|
| 35 |
// Peer management messages |
| 36 |
message RegisterPeerRequest { |
| 37 |
PeerInfo peer = 1; |
| 38 |
} |
| 39 |
|
| 40 |
message RegisterPeerResponse { |
| 41 |
bool success = 1; |
| 42 |
string message = 2; |
| 43 |
} |
| 44 |
|
| 45 |
message GetPeersRequest { |
| 46 |
int32 limit = 1; |
| 47 |
} |
| 48 |
|
| 49 |
message GetPeersResponse { |
| 50 |
repeated PeerInfo peers = 1; |
| 51 |
} |
| 52 |
|
| 53 |
// Chunk storage messages |
| 54 |
message StoreChunkRequest { |
| 55 |
string chunk_id = 1; |
| 56 |
bytes data = 2; |
| 57 |
string hash = 3; |
| 58 |
int64 size = 4; |
| 59 |
map<string, string> metadata = 5; |
| 60 |
} |
| 61 |
|
| 62 |
message StoreChunkResponse { |
| 63 |
bool success = 1; |
| 64 |
string message = 2; |
| 65 |
string stored_hash = 3; |
| 66 |
} |
| 67 |
|
| 68 |
message RetrieveChunkRequest { |
| 69 |
string chunk_id = 1; |
| 70 |
string expected_hash = 2; |
| 71 |
} |
| 72 |
|
| 73 |
message RetrieveChunkResponse { |
| 74 |
bool success = 1; |
| 75 |
string message = 2; |
| 76 |
bytes data = 3; |
| 77 |
string hash = 4; |
| 78 |
int64 size = 5; |
| 79 |
} |
| 80 |
|
| 81 |
message DeleteChunkRequest { |
| 82 |
string chunk_id = 1; |
| 83 |
string reason = 2; |
| 84 |
} |
| 85 |
|
| 86 |
message DeleteChunkResponse { |
| 87 |
bool success = 1; |
| 88 |
string message = 2; |
| 89 |
} |
| 90 |
|
| 91 |
// Metadata messages |
| 92 |
message StoreMetadataRequest { |
| 93 |
string file_id = 1; |
| 94 |
FileMetadata metadata = 2; |
| 95 |
} |
| 96 |
|
| 97 |
message StoreMetadataResponse { |
| 98 |
bool success = 1; |
| 99 |
string message = 2; |
| 100 |
} |
| 101 |
|
| 102 |
message RetrieveMetadataRequest { |
| 103 |
string file_id = 1; |
| 104 |
} |
| 105 |
|
| 106 |
message RetrieveMetadataResponse { |
| 107 |
bool success = 1; |
| 108 |
string message = 2; |
| 109 |
FileMetadata metadata = 3; |
| 110 |
} |
| 111 |
|
| 112 |
// Data structures |
| 113 |
message NodeInfo { |
| 114 |
string node_id = 1; |
| 115 |
string version = 2; |
| 116 |
repeated string addresses = 3; |
| 117 |
int64 storage_available = 4; |
| 118 |
int64 storage_used = 5; |
| 119 |
int64 uptime_seconds = 6; |
| 120 |
string status = 7; |
| 121 |
} |
| 122 |
|
| 123 |
message PeerInfo { |
| 124 |
string peer_id = 1; |
| 125 |
repeated string addresses = 2; |
| 126 |
int64 last_seen = 3; |
| 127 |
string status = 4; |
| 128 |
double reputation_score = 5; |
| 129 |
} |
| 130 |
|
| 131 |
message FileMetadata { |
| 132 |
string file_id = 1; |
| 133 |
string name = 2; |
| 134 |
int64 size = 3; |
| 135 |
string mime_type = 4; |
| 136 |
string hash = 5; |
| 137 |
repeated ChunkInfo chunks = 6; |
| 138 |
int64 created_at = 7; |
| 139 |
int64 modified_at = 8; |
| 140 |
map<string, string> user_metadata = 9; |
| 141 |
} |
| 142 |
|
| 143 |
message ChunkInfo { |
| 144 |
string chunk_id = 1; |
| 145 |
string hash = 2; |
| 146 |
int64 size = 3; |
| 147 |
int32 index = 4; |
| 148 |
repeated string stored_at_peers = 5; |
| 149 |
} |