90 lines
2.4 KiB
Rust
90 lines
2.4 KiB
Rust
use crate::data_build_event::Event;
|
|
use crate::util::current_timestamp;
|
|
use crate::{
|
|
event_source, EventSource, JobRunStatus, JobRunStatusCode, JobTriggeredEvent,
|
|
ManuallyTriggeredEvent, PartitionRef, PartitionStatus, PartitionStatusCode, WantCancelEventV1,
|
|
WantCreateEventV1, WantDetail, WantStatus, WantStatusCode,
|
|
};
|
|
|
|
impl From<&WantCreateEventV1> for WantDetail {
|
|
fn from(e: &WantCreateEventV1) -> Self {
|
|
e.clone().into()
|
|
}
|
|
}
|
|
impl From<WantCreateEventV1> for WantDetail {
|
|
fn from(e: WantCreateEventV1) -> Self {
|
|
WantDetail {
|
|
want_id: e.want_id,
|
|
partitions: e.partitions,
|
|
upstreams: vec![],
|
|
data_timestamp: e.data_timestamp,
|
|
ttl_seconds: e.ttl_seconds,
|
|
sla_seconds: e.sla_seconds,
|
|
source: e.source,
|
|
comment: e.comment,
|
|
status: Some(Default::default()),
|
|
last_updated_timestamp: current_timestamp(),
|
|
}
|
|
}
|
|
}
|
|
impl From<WantCreateEventV1> for Event {
|
|
fn from(value: WantCreateEventV1) -> Self {
|
|
Event::WantCreateV1(value)
|
|
}
|
|
}
|
|
impl From<WantCancelEventV1> for Event {
|
|
fn from(value: WantCancelEventV1) -> Self {
|
|
Event::WantCancelV1(value)
|
|
}
|
|
}
|
|
|
|
impl From<WantStatusCode> for WantStatus {
|
|
fn from(code: WantStatusCode) -> Self {
|
|
WantStatus {
|
|
code: code.into(),
|
|
name: code.as_str_name().to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<&str> for PartitionRef {
|
|
fn from(value: &str) -> Self {
|
|
Self {
|
|
r#ref: value.to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<PartitionStatusCode> for PartitionStatus {
|
|
fn from(code: PartitionStatusCode) -> Self {
|
|
PartitionStatus {
|
|
code: code.into(),
|
|
name: code.as_str_name().to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<JobRunStatusCode> for JobRunStatus {
|
|
fn from(code: JobRunStatusCode) -> Self {
|
|
JobRunStatus {
|
|
code: code.into(),
|
|
name: code.as_str_name().to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<ManuallyTriggeredEvent> for EventSource {
|
|
fn from(value: ManuallyTriggeredEvent) -> Self {
|
|
Self {
|
|
source: Some(event_source::Source::ManuallyTriggered(value)),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<JobTriggeredEvent> for EventSource {
|
|
fn from(value: JobTriggeredEvent) -> Self {
|
|
Self {
|
|
source: Some(event_source::Source::JobTriggered(value)),
|
|
}
|
|
}
|
|
}
|