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
use serde::{Deserialize, Serialize};
/// Where a background embedding pass over one library stands.
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum EmbeddingPassState {
/// Sent before the model is loaded and, the first time, downloaded.
Started,
/// Sent after each media.
Running,
Completed,
/// Left because the library was paused; resuming starts a new pass.
Paused,
/// Left because embeddings were turned off for the library, or it was removed.
Stopped,
/// Left early after too many failures in a row; a later pass carries on.
Interrupted,
/// Could not run, for example because the model cannot be loaded.
Failed,
}
/// Payload of the `embedding_progress` event. A pass sends `started` once, `running`
/// after each media, then exactly one of `completed`, `paused`, `stopped`,
/// `interrupted` or `failed`.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct EmbeddingProgressMessage {
pub library: String,
pub state: EmbeddingPassState,
pub embedder: String,
/// Medias tried so far in this pass.
pub processed: u64,
/// Of which embedded; the others failed.
pub embedded: u64,
/// Medias this pass covers: those pending when it started, kept in step with
/// uploads and deletions since. Never below `processed`.
pub total: u64,
}