feldera_types/completion_token.rs
1use serde::{Deserialize, Serialize};
2use utoipa::ToSchema;
3
4/// Response to a completion token creation request.
5#[derive(Debug, Serialize, Deserialize, ToSchema)]
6pub struct CompletionTokenResponse {
7 /// Completion token.
8 ///
9 /// An opaque string associated with the current position in the input stream
10 /// generated by an input connector.
11 /// Pass this string to the `/completion_status` endpoint to check whether all
12 /// inputs associated with the token have been fully processed by the pipeline.
13 pub token: String,
14}
15
16impl CompletionTokenResponse {
17 pub fn new(token: String) -> Self {
18 Self { token }
19 }
20}
21
22/// URL-encoded arguments to the `/completion_status` endpoint.
23#[derive(Clone, Debug, PartialEq, Deserialize, ToSchema)]
24pub struct CompletionStatusArgs {
25 /// Completion token returned by the `/completion_token` or `/ingress`
26 /// endpoint.
27 pub token: String,
28}
29
30/// Completion token status returned by the `/completion_status` endpoint.
31#[derive(Debug, Serialize, Deserialize, ToSchema, PartialEq, Eq)]
32pub enum CompletionStatus {
33 /// All inputs associated with the token have been processed to completion.
34 #[serde(rename = "complete")]
35 Complete,
36
37 /// The pipeline is still processing input updates associated with the token.
38 #[serde(rename = "inprogress")]
39 InProgress,
40}
41
42/// Response to a completion token status request.
43#[derive(Debug, Serialize, Deserialize, ToSchema)]
44pub struct CompletionStatusResponse {
45 /// Completion token status.
46 pub status: CompletionStatus,
47}
48
49impl CompletionStatusResponse {
50 pub fn complete() -> Self {
51 Self {
52 status: CompletionStatus::Complete,
53 }
54 }
55
56 pub fn inprogress() -> Self {
57 Self {
58 status: CompletionStatus::InProgress,
59 }
60 }
61}