pub struct CreateProcessInstanceRequest<T: CreateProcessInstanceState> { /* private fields */ }Expand description
Request to create a process instance in Zeebe
This builder-like struct allows you to configure and send a request to create a new process instance in the Zeebe workflow engine. The request goes through several states to ensure all required parameters are set before sending.
§Examples
// Create a process instance with a BPMN process ID and no input variables
client
.create_process_instance()
.with_bpmn_process_id(String::from("order-process"))
.without_input()
.send()
.await?;
// Create a process instance with a process definition key and input variables
client
.create_process_instance()
.with_process_definition_key(12345)
.with_variables(json!({"orderId": 123}))
.unwrap()
.send()
.await?;Implementations§
Source§impl CreateProcessInstanceRequest<Initial>
impl CreateProcessInstanceRequest<Initial>
Sourcepub fn with_bpmn_process_id(
self,
bpmn_process_id: String,
) -> CreateProcessInstanceRequest<WithProcess>
pub fn with_bpmn_process_id( self, bpmn_process_id: String, ) -> CreateProcessInstanceRequest<WithProcess>
Sourcepub fn with_process_definition_key(
self,
process_definition_key: i64,
) -> CreateProcessInstanceRequest<WithProcess>
pub fn with_process_definition_key( self, process_definition_key: i64, ) -> CreateProcessInstanceRequest<WithProcess>
Sets the process definition key to identify in which process to instantiate.
§Arguments
process_definition_key- The unique key identifying the process definition.
§Returns
A CreateProcessInstanceRequest<WithProcess> to continue the request building.
Examples found in repository?
31async fn place_order(
32 client: Client,
33 process_definition_key: i64,
34 name: &str,
35 address: &str,
36 bad_tipper: bool,
37 items: Vec<&str>,
38) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
39 let customer = Customer {
40 name: name.to_owned(),
41 address: address.to_owned(),
42 bad_tipper,
43 customer_id: format!("{}_{}", name, address),
44 };
45
46 let order = Order {
47 items: items.into_iter().map(|x| x.to_owned()).collect(),
48 };
49
50 let res = client
51 .create_process_instance()
52 .with_process_definition_key(process_definition_key)
53 .with_variables(customer.clone())?
54 .send()
55 .await?;
56
57 println!("{:?}", res);
58
59 let res = client
60 .publish_message()
61 .with_name(String::from("order_pizza_msg"))
62 .with_correlation_key(customer.customer_id.clone())
63 .with_variables(order)?
64 .send()
65 .await?;
66
67 println!("{:?}", res);
68
69 Ok(())
70}Source§impl CreateProcessInstanceRequest<WithProcess>
impl CreateProcessInstanceRequest<WithProcess>
Sourcepub fn with_variables<T: Serialize>(
self,
variables: T,
) -> Result<CreateProcessInstanceRequest<WithVariables>, ClientError>
pub fn with_variables<T: Serialize>( self, variables: T, ) -> Result<CreateProcessInstanceRequest<WithVariables>, ClientError>
Sets the variables to instantiate the process with.
§Arguments
variables- Variables that will be used as instance payload.
§Errors
Returns ClientError if variables cannot be serialized to JSON.
§Returns
A Result containing either a CreateProcessInstanceRequest<WithVariables> if successful, or a ClientError if serialization fails.
Examples found in repository?
31async fn place_order(
32 client: Client,
33 process_definition_key: i64,
34 name: &str,
35 address: &str,
36 bad_tipper: bool,
37 items: Vec<&str>,
38) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
39 let customer = Customer {
40 name: name.to_owned(),
41 address: address.to_owned(),
42 bad_tipper,
43 customer_id: format!("{}_{}", name, address),
44 };
45
46 let order = Order {
47 items: items.into_iter().map(|x| x.to_owned()).collect(),
48 };
49
50 let res = client
51 .create_process_instance()
52 .with_process_definition_key(process_definition_key)
53 .with_variables(customer.clone())?
54 .send()
55 .await?;
56
57 println!("{:?}", res);
58
59 let res = client
60 .publish_message()
61 .with_name(String::from("order_pizza_msg"))
62 .with_correlation_key(customer.customer_id.clone())
63 .with_variables(order)?
64 .send()
65 .await?;
66
67 println!("{:?}", res);
68
69 Ok(())
70}Sourcepub fn without_input(self) -> CreateProcessInstanceRequest<WithVariables>
pub fn without_input(self) -> CreateProcessInstanceRequest<WithVariables>
Creates the process instance without any input variables
§Returns
A CreateProcessInstanceRequest<WithVariables> to continue the request building.
Source§impl CreateProcessInstanceRequest<WithVariables>
impl CreateProcessInstanceRequest<WithVariables>
Sourcepub async fn send(self) -> Result<CreateProcessInstanceResponse, ClientError>
pub async fn send(self) -> Result<CreateProcessInstanceResponse, ClientError>
Sends the process instance creation request to the Zeebe workflow engine.
§Errors
Returns ClientError if the request fails.
Examples found in repository?
31async fn place_order(
32 client: Client,
33 process_definition_key: i64,
34 name: &str,
35 address: &str,
36 bad_tipper: bool,
37 items: Vec<&str>,
38) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
39 let customer = Customer {
40 name: name.to_owned(),
41 address: address.to_owned(),
42 bad_tipper,
43 customer_id: format!("{}_{}", name, address),
44 };
45
46 let order = Order {
47 items: items.into_iter().map(|x| x.to_owned()).collect(),
48 };
49
50 let res = client
51 .create_process_instance()
52 .with_process_definition_key(process_definition_key)
53 .with_variables(customer.clone())?
54 .send()
55 .await?;
56
57 println!("{:?}", res);
58
59 let res = client
60 .publish_message()
61 .with_name(String::from("order_pizza_msg"))
62 .with_correlation_key(customer.customer_id.clone())
63 .with_variables(order)?
64 .send()
65 .await?;
66
67 println!("{:?}", res);
68
69 Ok(())
70}Sourcepub fn with_result(
self,
fetch_variables: Option<Vec<String>>,
) -> CreateProcessInstanceRequest<WithResult>
pub fn with_result( self, fetch_variables: Option<Vec<String>>, ) -> CreateProcessInstanceRequest<WithResult>
Sourcepub fn with_version(self, version: i32) -> Self
pub fn with_version(self, version: i32) -> Self
Sourcepub fn with_tenant_id(self, tenant_id: String) -> Self
pub fn with_tenant_id(self, tenant_id: String) -> Self
Sourcepub fn with_operation_reference(self, operation_reference: u64) -> Self
pub fn with_operation_reference(self, operation_reference: u64) -> Self
Source§impl CreateProcessInstanceRequest<WithResult>
impl CreateProcessInstanceRequest<WithResult>
Sourcepub async fn send_with_serialized_result(
self,
) -> Result<CreateProcessInstanceWithResultSerialized, ClientError>
pub async fn send_with_serialized_result( self, ) -> Result<CreateProcessInstanceWithResultSerialized, ClientError>
Sends the request and returns serialized result variables as JSON.
§Errors
Returns ClientError if the request fails.
Sourcepub async fn send_with_result<T: DeserializeOwned>(
self,
) -> Result<CreateProcessInstanceWithResult<T>, ClientError>
pub async fn send_with_result<T: DeserializeOwned>( self, ) -> Result<CreateProcessInstanceWithResult<T>, ClientError>
Sends the request and deserializes result variables into the specified type.
§Errors
Returns ClientError if the request fails or deserialization fails.
Trait Implementations§
Source§impl<T: Clone + CreateProcessInstanceState> Clone for CreateProcessInstanceRequest<T>
impl<T: Clone + CreateProcessInstanceState> Clone for CreateProcessInstanceRequest<T>
Source§fn clone(&self) -> CreateProcessInstanceRequest<T>
fn clone(&self) -> CreateProcessInstanceRequest<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<T> !Freeze for CreateProcessInstanceRequest<T>
impl<T> !RefUnwindSafe for CreateProcessInstanceRequest<T>
impl<T> Send for CreateProcessInstanceRequest<T>where
T: Send,
impl<T> Sync for CreateProcessInstanceRequest<T>where
T: Sync,
impl<T> Unpin for CreateProcessInstanceRequest<T>where
T: Unpin,
impl<T> !UnwindSafe for CreateProcessInstanceRequest<T>
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<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