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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Flowmium is a workflow orchestrator that uses Kubernetes.
//! Flowmium is generally deployed as a binary and workflows are defined in YAML or Python and it also exposes an HTTP API.
//! This documentation is for those who are interested in the client library or integrating flowmium
//! into an existing Rust project instead of using the HTTP API.
//!
//! # Getting started
//! - Client library [`crate::requests`]
//! - [Deploying flowmium](https://github.com/RainingComputers/Flowmium/tree/main/examples/deployment)
//! - [Client CLI usage](https://github.com/RainingComputers/Flowmium#flowctl-cli)
//!
//! # Integrating into an existing Rust project
//! A simple example that creates runs a workflow with a single task that prints `Hello world`.
//!
//! ```no_run
//! use flowmium::driver;
//! use flowmium::executor;
//! use flowmium::scheduler;
//! use flowmium::secrets;
//!
//! use flowmium::model::*;
//!
//! #[tokio::main]
//! async fn main() {
//!     let subscriber = tracing_subscriber::FmtSubscriber::new();
//!     tracing::subscriber::set_global_default(subscriber).unwrap();
//!
//!     let pool = driver::get_default_postgres_pool().await.unwrap();
//!
//!     let executor_config = driver::get_default_executor_config().await.unwrap();
//!
//!     let scheduler = scheduler::Scheduler::new(pool.clone());
//!
//!     let secrets = secrets::SecretsCrud::new(pool.clone());
//!     secrets
//!         .create_secret("super-secret-message", "hello world")
//!         .await
//!         .unwrap();
//!
//!     let handle = driver::spawn_executor(&pool, &scheduler, &executor_config);
//!
//!     let flow = create_example_flow();
//!     executor::instantiate_flow(flow, &scheduler).await.unwrap();
//!
//!     handle.await.unwrap();
//! }
//!
//! fn create_example_flow() -> Flow {
//!     Flow {
//!         name: "hello-world".to_string(),
//!         tasks: vec![Task {
//!             name: "hello-world".to_string(),
//!             image: "debian:latest".to_string(),
//!             depends: vec![],
//!             cmd: vec![
//!                 "sh".to_string(),
//!                 "-c".to_string(),
//!                 "echo $MESSAGE".to_string(),
//!             ],
//!             env: vec![EnvVar::SecretRef(SecretRef {
//!                 name: "MESSAGE".to_string(),
//!                 from_secret: "super-secret-message".to_string(),
//!             })],
//!             inputs: None,
//!             outputs: None,
//!         }],
//!     }
//! }
//! ```
//!
//! To run the example, you will have to run something like below
//!
//! ```shell
//! export FLOWMIUM_POSTGRES_URL='postgres://flowmium:flowmium@localhost/flowmium'
//! export FLOWMIUM_STORE_URL='http://localhost:9000'
//! export FLOWMIUM_TASK_STORE_URL='http://172.16.238.4:9000'
//! export FLOWMIUM_BUCKET_NAME='flowmium-test'
//! export FLOWMIUM_ACCESS_KEY='minio'
//! export FLOWMIUM_SECRET_KEY='password'
//! export FLOWMIUM_INIT_CONTAINER_IMAGE='docker.io/shnoo28/flowmium:latest'
//! export FLOWMIUM_NAMESPACE=default
//! export KUBECONFIG=./kubeconfig.yaml
//! cargo run
//! ```

mod client;
mod retry;
mod server;
mod task;

pub use client::driver as driver_client;
pub use client::requests;
pub use server::driver;
pub use server::event;
pub use server::executor;
pub use server::model;
pub use server::planner;
pub use server::record;
pub use server::scheduler;
pub use server::secrets;