pub struct FlowDefinitionDocument { /* private fields */ }Expand description
Holds one Flow Definition Graph JSON document in memory for upload to the Dex Server.
Dex Web draws a Flow type’s graph from the document stored for it. Pass documents to
crate::WorkerOptions::flow_definitions to upload them when a Worker starts, or to
crate::Client::upload_flow_definitions from a deploy script. Use
crate::WorkerOptions::flow_definition_paths instead when the documents are files, such as
the output of dexcli visualize.
The Flow type must equal flow.name in the content. The content must be a UTF-8 JSON object
whose schemaVersion starts with 2.. The Dex Server compares generated_at with the stored
document: a different document replaces the stored one only when its generation time is
strictly later. Pass a fixed time for a document generated from a template, such as the
template’s release time, so every Worker sends the same time.
Debug prints the content length, not the content.
Since 1.45.0.
§Examples
use std::time::{Duration, SystemTime};
use dex_sdk::{FlowDefinitionDocument, WorkerOptions};
let content = std::fs::read("flow-definitions/OrderFlow.json")?;
let generated_at = SystemTime::UNIX_EPOCH + Duration::from_secs(1_793_491_200);
let options = WorkerOptions::new().flow_definitions([FlowDefinitionDocument::new(
"OrderFlow",
content,
generated_at,
)]);Implementations§
Source§impl FlowDefinitionDocument
impl FlowDefinitionDocument
Sourcepub fn new(
flow_type: impl Into<String>,
content: impl Into<Vec<u8>>,
generated_at: SystemTime,
) -> Self
pub fn new( flow_type: impl Into<String>, content: impl Into<Vec<u8>>, generated_at: SystemTime, ) -> Self
Creates a document from its Flow type, JSON content, and generation time.
flow_type must equal flow.name in content, and content must hold the UTF-8 JSON
bytes of the Flow Definition Graph. The constructor does not validate them.
crate::Worker::try_new returns crate::SdkError::FlowDefinition, and
crate::Client::upload_flow_definitions returns crate::SdkError::InvalidArgument,
when a document is not a UTF-8 JSON object whose schemaVersion starts with 2. and whose
flow.name equals the Flow type. The Dex Server rejects other invalid documents.
Since 1.45.0.
Sourcepub fn flow_type(&self) -> &str
pub fn flow_type(&self) -> &str
Returns the Flow type that the document describes.
Since 1.45.0.
Sourcepub fn generated_at(&self) -> SystemTime
pub fn generated_at(&self) -> SystemTime
Returns the time when the document was generated.
Since 1.45.0.
Trait Implementations§
Source§impl Clone for FlowDefinitionDocument
impl Clone for FlowDefinitionDocument
Source§impl Debug for FlowDefinitionDocument
impl Debug for FlowDefinitionDocument
impl Eq for FlowDefinitionDocument
Source§impl PartialEq for FlowDefinitionDocument
impl PartialEq for FlowDefinitionDocument
impl StructuralPartialEq for FlowDefinitionDocument
Auto Trait Implementations§
impl Forget for FlowDefinitionDocument
impl Freeze for FlowDefinitionDocument
impl Move for FlowDefinitionDocument
impl RefUnwindSafe for FlowDefinitionDocument
impl Send for FlowDefinitionDocument
impl Sync for FlowDefinitionDocument
impl Unpin for FlowDefinitionDocument
impl UnsafeUnpin for FlowDefinitionDocument
impl UnwindSafe for FlowDefinitionDocument
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request