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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Durable workflows: a flow of steps written as one async function, which survives deploys,
//! worker crashes, and sleeps of days in between.
//!
//! A workflow is a [`Queueable`](crate::queue::Queueable) struct with a [`#[workflow]`](macro@workflow)
//! impl. Its `handle` takes a [`&Run`](Run), and every durable operation is a method on the run.
//! Each step runs once, and the framework records its result in a [store](store::Store), so a
//! run that stops for any reason continues from the last recorded step:
//!
//! ```no_run
//! use laravel::queue::Queueable;
//! use laravel::time::ToSpan;
//! use laravel::workflow::{Run, workflow};
//!
//! #[derive(Queueable)]
//! pub struct OnboardUser {
//! pub user_id: i64,
//! }
//!
//! #[workflow]
//! impl OnboardUser {
//! async fn handle(self, run: &Run) -> laravel::Result<()> {
//! run.step("send welcome email", self.send_welcome_email()).await?;
//!
//! run.sleep(3.days()).await?;
//!
//! run.step("send tips", self.send_tips()).await
//! }
//! }
//!
//! impl OnboardUser {
//! async fn send_welcome_email(&self) -> laravel::Result<()> {
//! // ...
//! Ok(())
//! }
//!
//! async fn send_tips(&self) -> laravel::Result<()> {
//! // ...
//! Ok(())
//! }
//! }
//!
//! # async fn example() -> laravel::Result<()> {
//! let run_id = OnboardUser { user_id: 42 }.start().await?;
//! # Ok(()) }
//! ```
//!
//! Each advance of a run is a job on the application's queue, so runs need a queue worker. The
//! [workflows guide](https://github.com/laravel/rust-framework/blob/0.x/docs/workflows.md) describes
//! replays, determinism rules, and testing.
pub use *;
pub use ;
pub use ;
/// Define a migration's `migrate` function to create the `database` workflow store's tables.
///
/// Put the macro alone in a migration file, and it creates the `workflow_runs`, `workflow_steps`,
/// `workflow_waits`, `workflow_resumes`, and `workflow_attributes` tables. To change the
/// tables, replace the macro with the migration the
/// [workflows guide](https://github.com/laravel/rust-framework/blob/0.x/docs/workflows.md#the-workflow-tables) shows,
/// then edit it.
///
/// ```
/// // database/migrations/0001_01_01_000003_create_workflow_tables.rs
/// laravel::workflow::tables!();
/// ```
pub use workflow_tables as tables;