chore(infra): add gRPC layer, update protobufs, remove immediate module

- Add gRPC service modules: auth, channel, channel settings, member,
  permission
- Update protobuf definitions and generated code
- Remove immediate/ real-time module (superseded by IM service)
- Update etcd discovery and registration
- Update cache, error, config, and build infrastructure
- Add ADR documentation
- Update OpenAPI spec
This commit is contained in:
zhenyi
2026-06-10 18:49:42 +08:00
parent 9eb77ab98b
commit 1000f8a80d
57 changed files with 22524 additions and 2703 deletions
+299
View File
@@ -139,6 +139,276 @@ message RepositoryMaintenanceResponse {
string stderr = 3;
}
message ListHooksRequest {
RepositoryHeader repository = 1;
}
message HookInfo {
string hook_type = 1;
string level = 2; // "server" or "custom"
string path = 3;
}
message ListHooksResponse {
repeated HookInfo hooks = 1;
}
message SetCustomHookRequest {
RepositoryHeader repository = 1;
string hook_name = 2; // "pre-receive", "update", "post-receive"
string content = 3; // Hook script content
}
message RemoveCustomHookRequest {
RepositoryHeader repository = 1;
string hook_name = 2;
}
enum SnapshotStorage {
SNAPSHOT_STORAGE_LOCAL = 0;
SNAPSHOT_STORAGE_S3 = 1;
SNAPSHOT_STORAGE_GCS = 2;
}
message SnapshotInfo {
string snapshot_id = 1;
string relative_path = 2;
uint64 size_bytes = 3;
string created_at = 4; // ISO 8601
string head_oid = 5;
}
message CreateSnapshotRequest {
RepositoryHeader repository = 1;
SnapshotStorage storage = 2;
string storage_path = 3;
}
message CreateSnapshotResponse {
string snapshot_id = 1;
uint64 size_bytes = 2;
string head_oid = 3;
}
message RestoreSnapshotRequest {
RepositoryHeader target_repository = 1;
string snapshot_id = 2;
SnapshotStorage storage = 3;
string storage_path = 4;
}
message ListSnapshotsRequest {
RepositoryHeader repository = 1;
uint32 limit = 2;
}
message ListSnapshotsResponse {
repeated SnapshotInfo snapshots = 1;
}
message DeleteSnapshotRequest {
string snapshot_id = 1;
SnapshotStorage storage = 2;
}
enum MoveRepositoryState {
MOVE_STATE_UNKNOWN = 0;
MOVE_STATE_PREPARING = 1;
MOVE_STATE_TRANSFERRING = 2;
MOVE_STATE_VERIFYING = 3;
MOVE_STATE_COMPLETED = 4;
MOVE_STATE_FAILED = 5;
MOVE_STATE_CANCELLED = 6;
}
message MoveRepositoryRequest {
RepositoryHeader source_repository = 1;
RepositoryHeader target_repository = 2;
}
message MoveRepositoryResponse {
MoveRepositoryState state = 1;
string error_message = 2;
}
message FetchRepositoryDataRequest {
RepositoryHeader repository = 1;
}
message FetchRepositoryDataResponse {
bytes data = 1;
bool done = 2;
}
message FindMergeBaseRequest {
RepositoryHeader repository = 1;
repeated bytes revisions = 2; // hex OIDs to find merge-base for
}
message FindMergeBaseResponse {
string base_oid = 1;
}
message WriteRefRequest {
RepositoryHeader repository = 1;
string ref_name = 2;
string new_oid = 3;
string old_oid = 4; // expected old OID (empty = no check)
bool force = 5;
}
message WriteRefResponse {
bool ok = 1;
string error = 2;
}
message SearchFilesByContentRequest {
RepositoryHeader repository = 1;
string query = 2; // regex pattern
string revision = 3; // tree-ish to search in (default HEAD)
uint32 max_results = 4; // default 100
bool case_sensitive = 5;
}
message SearchFilesByContentResponse {
repeated SearchResult results = 1;
}
message SearchFilesByNameRequest {
RepositoryHeader repository = 1;
string query = 2; // regex pattern for file names
string revision = 3;
uint32 max_results = 4;
bool recursive = 5;
}
message SearchFilesByNameResponse {
repeated SearchResult results = 1;
}
message SearchResult {
string path = 1;
uint32 line = 2; // 0 for name-only search
string matched_text = 3; // the surrounding line content
}
message ObjectsSizeRequest {
RepositoryHeader repository = 1;
repeated string oids = 2;
}
message ObjectsSizeResponse {
repeated ObjectSize sizes = 1;
}
message ObjectSize {
string oid = 1;
uint64 size = 2;
bool found = 3;
}
message RepositorySizeRequest {
RepositoryHeader repository = 1;
}
message RepositorySizeResponse {
uint64 size_bytes = 1;
}
message FindLicenseRequest {
RepositoryHeader repository = 1;
}
message FindLicenseResponse {
string license_spdx = 1; // SPDX identifier, e.g. "MIT"
string license_name = 2; // human-readable name
double confidence = 3; // 0.0 — 1.0
string license_path = 4; // path to LICENSE file
}
enum OptimizeStrategy {
OPTIMIZE_STRATEGY_UNSPECIFIED = 0;
OPTIMIZE_STRATEGY_HEURISTIC = 1; // auto-decide based on repo state
OPTIMIZE_STRATEGY_AGGRESSIVE = 2;
OPTIMIZE_STRATEGY_INCREMENTAL = 3;
}
message OptimizeRepositoryRequest {
RepositoryHeader repository = 1;
OptimizeStrategy strategy = 2;
}
message OptimizeRepositoryResponse {
bool ok = 1;
string stdout = 2;
string stderr = 3;
}
message GetRawChangesRequest {
RepositoryHeader repository = 1;
string base = 2; // revision or OID
string head = 3;
}
message RawChange {
enum Operation {
RAW_CHANGE_OPERATION_UNSPECIFIED = 0;
RAW_CHANGE_OPERATION_ADDED = 1;
RAW_CHANGE_OPERATION_MODIFIED = 2;
RAW_CHANGE_OPERATION_DELETED = 3;
RAW_CHANGE_OPERATION_RENAMED = 4;
RAW_CHANGE_OPERATION_COPIED = 5;
}
Operation operation = 1;
string old_path = 2;
string new_path = 3;
uint32 old_mode = 4;
uint32 new_mode = 5;
string old_oid = 6;
string new_oid = 7;
double similarity = 8;
}
message GetRawChangesResponse {
repeated RawChange changes = 1;
}
message FetchRemoteRequest {
RepositoryHeader repository = 1;
string remote_url = 2;
string remote_name = 3; // defaults to "origin"
repeated string refspecs = 4;
bool force = 5;
bool prune = 6;
}
message FetchRemoteResponse {
bool ok = 1;
string error = 2;
}
message CreateRepositoryFromURLRequest {
RepositoryHeader repository = 1;
string remote_url = 2;
bool mirror = 3;
}
message CreateRepositoryFromURLResponse {
Repository repository = 1;
}
service RepositoryService {
rpc GetRepository(GetRepositoryRequest) returns (Repository);
rpc InitRepository(InitRepositoryRequest) returns (Repository);
@@ -154,4 +424,33 @@ service RepositoryService {
rpc GarbageCollect(GarbageCollectRequest) returns (RepositoryMaintenanceResponse);
rpc Repack(RepackRequest) returns (RepositoryMaintenanceResponse);
rpc WriteCommitGraph(WriteCommitGraphRequest) returns (RepositoryMaintenanceResponse);
// Hooks management
rpc ListHooks(ListHooksRequest) returns (ListHooksResponse);
rpc SetCustomHook(SetCustomHookRequest) returns (google.protobuf.Empty);
rpc RemoveCustomHook(RemoveCustomHookRequest) returns (google.protobuf.Empty);
// Snapshot operations
rpc CreateSnapshot(CreateSnapshotRequest) returns (CreateSnapshotResponse);
rpc RestoreSnapshot(RestoreSnapshotRequest) returns (google.protobuf.Empty);
rpc ListSnapshots(ListSnapshotsRequest) returns (ListSnapshotsResponse);
rpc DeleteSnapshot(DeleteSnapshotRequest) returns (google.protobuf.Empty);
// Repository move
rpc MoveRepository(MoveRepositoryRequest) returns (MoveRepositoryResponse);
rpc FetchRepositoryData(FetchRepositoryDataRequest) returns (stream FetchRepositoryDataResponse);
rpc FindMergeBase(FindMergeBaseRequest) returns (FindMergeBaseResponse);
rpc WriteRef(WriteRefRequest) returns (WriteRefResponse);
rpc SearchFilesByContent(SearchFilesByContentRequest) returns (SearchFilesByContentResponse);
rpc SearchFilesByName(SearchFilesByNameRequest) returns (SearchFilesByNameResponse);
rpc ObjectsSize(ObjectsSizeRequest) returns (ObjectsSizeResponse);
rpc RepositorySize(RepositorySizeRequest) returns (RepositorySizeResponse);
rpc FetchRemote(FetchRemoteRequest) returns (FetchRemoteResponse);
rpc CreateRepositoryFromURL(CreateRepositoryFromURLRequest) returns (CreateRepositoryFromURLResponse);
rpc FindLicense(FindLicenseRequest) returns (FindLicenseResponse);
rpc OptimizeRepository(OptimizeRepositoryRequest) returns (OptimizeRepositoryResponse);
rpc GetRawChanges(GetRawChangesRequest) returns (GetRawChangesResponse);
}