Skip to content

Commit c765e80

Browse files
committed
docs(guide): update guidance to include new features
1 parent 2c8ecaf commit c765e80

3 files changed

Lines changed: 172 additions & 2 deletions

File tree

guide/src/client/sdk.md

Lines changed: 131 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Add the following to your `Cargo.toml`:
99

1010
```toml
1111
[dependencies]
12-
netmito = "0.6.0"
12+
netmito = "0.6.5"
1313
tokio = { version = "1.0", features = ["full"] }
1414
uuid = { version = "1.18", features = ["v4"] }
1515
```
@@ -212,6 +212,136 @@ let args = GroupAttachmentDownloadArgs {
212212
client.group_attachment_download(args).await?;
213213
```
214214

215+
### Batch Operations (v0.6.5+)
216+
217+
Starting from version 0.6.5, the SDK supports batch operations for improved efficiency when working with multiple resources:
218+
219+
#### Batch Task Submission
220+
221+
Submit multiple tasks at once:
222+
223+
```rust,ignore
224+
use netmito::config::client::TaskSubmitArgs;
225+
use netmito::schema::BatchTaskSubmitReq;
226+
227+
let tasks = vec![
228+
TaskSubmitArgs {
229+
command: vec!["echo".to_string(), "task1".to_string()],
230+
group: Some("my-group".to_string()),
231+
..Default::default()
232+
},
233+
TaskSubmitArgs {
234+
command: vec!["echo".to_string(), "task2".to_string()],
235+
group: Some("my-group".to_string()),
236+
..Default::default()
237+
},
238+
];
239+
240+
let batch_req = BatchTaskSubmitReq { tasks };
241+
let task_ids = client.batch_submit_tasks(batch_req).await?;
242+
```
243+
244+
#### Batch Task Cancellation
245+
246+
Cancel multiple tasks by UUID or by filter:
247+
248+
```rust,ignore
249+
use uuid::Uuid;
250+
use netmito::schema::BatchCancelByUuidsReq;
251+
252+
// Cancel by specific UUIDs
253+
let task_ids = vec![
254+
Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")?,
255+
Uuid::parse_str("660e8400-e29b-41d4-a716-446655440001")?,
256+
];
257+
let req = BatchCancelByUuidsReq { uuids: task_ids };
258+
client.tasks_batch_cancel_by_uuids(req).await?;
259+
260+
// Or cancel by filter
261+
use netmito::config::client::TaskQueryArgs;
262+
let filter = TaskQueryArgs {
263+
labels: Some(vec!["test".to_string()]),
264+
status: Some("pending".to_string()),
265+
..Default::default()
266+
};
267+
client.tasks_batch_cancel(filter).await?;
268+
```
269+
270+
#### Batch Artifact Download
271+
272+
Download multiple artifacts at once:
273+
274+
```rust,ignore
275+
use netmito::config::client::{TaskQueryArgs, TaskArtifactDownloadArgs};
276+
277+
// Download artifacts by filter
278+
let filter = TaskQueryArgs {
279+
labels: Some(vec!["experiment-1".to_string()]),
280+
status: Some("completed".to_string()),
281+
..Default::default()
282+
};
283+
let download_args = TaskArtifactDownloadArgs {
284+
artifact_type: "result".to_string(),
285+
output_path: Some("./results/".to_string()),
286+
..Default::default()
287+
};
288+
client.batch_download_artifacts_by_filter(filter, download_args).await?;
289+
290+
// Or download specific artifacts by task IDs
291+
use netmito::schema::BatchDownloadArtifactsByListReq;
292+
let req = BatchDownloadArtifactsByListReq {
293+
task_ids: vec![task_id1, task_id2],
294+
artifact_type: "result".to_string(),
295+
};
296+
client.batch_download_artifacts_by_list(req, "./results/".to_string()).await?;
297+
```
298+
299+
#### Batch Attachment Operations
300+
301+
Download or delete multiple group attachments:
302+
303+
```rust,ignore
304+
use netmito::config::client::GroupAttachmentQueryArgs;
305+
use netmito::schema::BatchDownloadAttachmentsByListReq;
306+
307+
// Download attachments by filter
308+
let filter = GroupAttachmentQueryArgs {
309+
group_name: Some("my-group".to_string()),
310+
key: Some("datasets/".to_string()), // prefix matching
311+
..Default::default()
312+
};
313+
client.batch_download_attachments_by_filter(filter, "./downloads/".to_string()).await?;
314+
315+
// Delete attachments by list
316+
let keys = vec!["old-data-1.tar.gz".to_string(), "old-data-2.tar.gz".to_string()];
317+
let req = BatchDownloadAttachmentsByListReq {
318+
group_name: "my-group".to_string(),
319+
keys,
320+
};
321+
client.batch_delete_attachments_by_list(req).await?;
322+
```
323+
324+
#### Batch Worker Cancellation
325+
326+
Cancel multiple workers at once:
327+
328+
```rust,ignore
329+
use netmito::schema::BatchCancelByUuidsReq;
330+
331+
// Cancel workers by UUIDs
332+
let worker_ids = vec![worker_uuid1, worker_uuid2];
333+
let req = BatchCancelByUuidsReq { uuids: worker_ids };
334+
client.workers_batch_cancel_by_uuids(req).await?;
335+
336+
// Or cancel by filter
337+
use netmito::config::client::WorkerQueryArgs;
338+
let filter = WorkerQueryArgs {
339+
tags: Some(vec!["deprecated".to_string()]),
340+
..Default::default()
341+
};
342+
client.workers_batch_cancel(filter).await?;
343+
```
344+
215345
## Advanced Usage
216346

217347
### Configuration Options

guide/src/guide/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/stack-rs/mitosis/releas
2424
**For a specific version** (adjust version number as needed, found at [releases] page):
2525

2626
```bash
27-
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/stack-rs/mitosis/releases/download/mito-v0.6.0/mito-installer.sh | sh
27+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/stack-rs/mitosis/releases/download/mito-v0.6.5/mito-installer.sh | sh
2828
```
2929

3030
The installer script will:

guide/src/guide/worker.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ lifetime = "7d"
4949
# groups are not set, default to the user's group
5050
# tags are not set
5151
file_log = false
52+
# shared_log is not set, default to false. When enabled, all workers share a centralized log file with daily rotation (max 3 files)
5253
# log_path is not set. It will use the default rolling log file path if file_log is set to true
54+
# - If shared_log is enabled and log_path is not set, it will use workers.log in cache directory
55+
# - If shared_log is disabled and log_path is not set, it will use {worker_uuid}.log in cache directory
5356
# lifetime is not set, default to the coordinator's setting
5457
```
5558

@@ -123,3 +126,40 @@ Options:
123126
-V, --version
124127
Print version
125128
```
129+
130+
## Logging Configuration
131+
132+
Workers support flexible logging configurations to help you track and debug task execution:
133+
134+
### File Logging
135+
136+
Enable file logging with the `--file-log` flag or by setting `file_log = true` in the configuration file. This will write worker logs to disk for persistent storage.
137+
138+
### Shared Rolling Logs (v0.6.5+)
139+
140+
Starting from version 0.6.5, workers support shared rolling logs - a centralized logging mechanism that allows multiple workers to write to the same log file with automatic daily rotation:
141+
142+
- **Shared Mode**: When `shared_log = true`, all workers write to a single `workers.log` file in the cache directory
143+
- **Individual Mode**: When `shared_log = false` (default), each worker writes to its own `{worker_uuid}.log` file
144+
- **Rotation**: Shared logs rotate daily with a maximum of 3 log files retained
145+
146+
This feature is particularly useful when managing multiple workers on the same machine, as it simplifies log management and aggregation.
147+
148+
**Example configuration:**
149+
150+
```toml
151+
[worker]
152+
file_log = true
153+
shared_log = true # Enable shared rolling logs
154+
# log_path is optional - if not specified, uses default cache directory
155+
```
156+
157+
**Note:** The cache directory location varies by platform:
158+
159+
- Linux: `$XDG_CACHE_HOME` or `$HOME/.cache/mitosis`
160+
- macOS: `$HOME/Library/Caches/mitosis`
161+
- Windows: `{FOLDERID_LocalAppData}\mitosis`
162+
163+
```
164+
165+
```

0 commit comments

Comments
 (0)