1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//! Goosefs Rust gRPC Client
//!
//! A Rust client library that communicates with Goosefs Master/Worker
//! via gRPC (tonic/protobuf). This is the **Layer 3** crate in the
//! Lance → OpenDAL → Goosefs architecture.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────┐
//! │ ★ High-Level API (recommended) │
//! │ GoosefsFileWriter — end-to-end file write pipeline │
//! │ GoosefsFileReader — end-to-end file read pipeline │
//! ├─────────────────────────────────────────────────────┤
//! │ MasterClient — File metadata CRUD (Master:9200) │
//! │ WorkerMgrClient — Worker discovery (Master:9200) │
//! │ VersionClient — Service handshake (Master:9200) │
//! │ WorkerClient — Block streaming (Worker:9203) │
//! ├─────────────────────────────────────────────────────┤
//! │ BlockMapper — file range → block read plans │
//! │ WorkerRouter — consistent hash block→worker │
//! ├─────────────────────────────────────────────────────┤
//! │ GrpcBlockReader — bidirectional streaming read │
//! │ GrpcBlockWriter — bidirectional streaming write │
//! └─────────────────────────────────────────────────────┘
//! ```
//!
//! # Quick Start — High-Level API
//!
//! ```rust,no_run
//! use std::sync::Arc;
//! use goosefs_sdk::context::FileSystemContext;
//! use goosefs_sdk::io::{GoosefsFileWriter, GoosefsFileReader};
//! use goosefs_sdk::config::GoosefsConfig;
//!
//! #[tokio::main]
//! async fn main() -> goosefs_sdk::error::Result<()> {
//! // Build once — the only call that performs TCP+SASL.
//! let ctx = FileSystemContext::connect(GoosefsConfig::new("127.0.0.1:9200")).await?;
//!
//! // Write a file (zero new connections — reuses ctx).
//! GoosefsFileWriter::write_file_with_context(ctx.clone(), "/my-file.txt", b"Hello!").await?;
//!
//! // Read it back.
//! let data = GoosefsFileReader::read_file_with_context(ctx.clone(), "/my-file.txt").await?;
//! println!("read {} bytes", data.len());
//!
//! Ok(())
//! }
//! ```
//!
//! # Low-Level API
//!
//! ```rust,no_run
//! use goosefs_sdk::client::MasterClient;
//! use goosefs_sdk::config::GoosefsConfig;
//!
//! #[tokio::main]
//! async fn main() -> goosefs_sdk::error::Result<()> {
//! let config = GoosefsConfig::default();
//! let master = MasterClient::connect(&config).await?;
//! let file_info = master.get_status("/my-file.txt").await?;
//! println!("file length: {:?}", file_info.length);
//! Ok(())
//! }
//! ```
// Re-export commonly used types for convenience.
pub use crate;
pub use crate;
pub use crateFileSystemContext;
pub use crateWritePType;
/// Generated protobuf / gRPC types from Goosefs `.proto` definitions.
///
/// The module layout must mirror the proto package hierarchy exactly so that
/// prost-generated `super::` relative paths resolve correctly:
///
/// ```text
/// proto (root)
/// ├── grpc — com.qcloud.cos.goosefs.grpc (WorkerNetAddress, BlockInfo …)
/// │ ├── file — com.qcloud.cos.goosefs.grpc.file (FileSystemMasterClientService)
/// │ ├── block — com.qcloud.cos.goosefs.grpc.block (BlockWorker, WorkerManagerMaster…)
/// │ ├── version — com.qcloud.cos.goosefs.grpc.version (ServiceVersionClientService)
/// │ └── fscommon — com.qcloud.cos.goosefs.grpc.fscommon (LoadDescendantPType)
/// └── proto — (intermediate)
/// ├── dataserver — com.qcloud.cos.goosefs.proto.dataserver
/// ├── security — com.qcloud.cos.goosefs.proto.security (Capability, DelegationToken)
/// ├── shared — com.qcloud.cos.goosefs.proto.shared (AccessControlList)
/// └── status — com.qcloud.cos.goosefs.proto.status (PStatus)
/// ```
///
/// Key path resolutions from generated code:
/// - `grpc::file` uses `super::Bits` → `grpc::Bits` ✓
/// - `grpc::file` uses `super::super::proto::security::Capability`
/// → `proto(root)::proto::security::Capability` ✓
/// - `proto::dataserver` uses `super::shared::*` → `proto(inner)::shared::*` ✓