flowmium/
lib.rs

1//! Flowmium is a workflow orchestrator that uses Kubernetes.
2//! Flowmium is generally deployed as a binary and workflows are defined in YAML or Python and it also exposes an HTTP API.
3//! This documentation is for those who are interested in the client library or integrating flowmium
4//! into an existing Rust project instead of using the HTTP API.
5//!
6//! # Getting started
7//! - Client library [`crate::requests`]
8//! - [Deploying flowmium](https://github.com/RainingComputers/Flowmium/tree/main/examples/deployment)
9//! - [Client CLI usage](https://github.com/RainingComputers/Flowmium#flowctl-cli)
10//!
11//! # Integrating into an existing Rust project
12//! A simple example that creates runs a workflow with a single task that prints `Hello world`.
13//!
14//! ```no_run
15//! use flowmium::driver;
16//! use flowmium::executor;
17//! use flowmium::scheduler;
18//! use flowmium::secrets;
19//!
20//! use flowmium::model::*;
21//!
22//! #[tokio::main]
23//! async fn main() {
24//!     let subscriber = tracing_subscriber::FmtSubscriber::new();
25//!     tracing::subscriber::set_global_default(subscriber).unwrap();
26//!
27//!     let pool = driver::get_default_postgres_pool().await.unwrap();
28//!
29//!     let executor_config = driver::get_default_executor_config().await.unwrap();
30//!
31//!     let scheduler = scheduler::Scheduler::new(pool.clone());
32//!
33//!     let secrets = secrets::SecretsCrud::new(pool.clone());
34//!     secrets
35//!         .create_secret("super-secret-message", "hello world")
36//!         .await
37//!         .unwrap();
38//!
39//!     let handle = driver::spawn_executor(&pool, &scheduler, &executor_config);
40//!
41//!     let flow = create_example_flow();
42//!     executor::instantiate_flow(flow, &scheduler).await.unwrap();
43//!
44//!     handle.await.unwrap();
45//! }
46//!
47//! fn create_example_flow() -> Flow {
48//!     Flow {
49//!         name: "hello-world".to_string(),
50//!         tasks: vec![Task {
51//!             name: "hello-world".to_string(),
52//!             image: "debian:latest".to_string(),
53//!             depends: vec![],
54//!             cmd: vec![
55//!                 "sh".to_string(),
56//!                 "-c".to_string(),
57//!                 "echo $MESSAGE".to_string(),
58//!             ],
59//!             env: vec![EnvVar::SecretRef(SecretRef {
60//!                 name: "MESSAGE".to_string(),
61//!                 from_secret: "super-secret-message".to_string(),
62//!             })],
63//!             inputs: None,
64//!             outputs: None,
65//!         }],
66//!     }
67//! }
68//! ```
69//!
70//! To run the example, you will have to run something like below
71//!
72//! ```shell
73//! export FLOWMIUM_POSTGRES_URL='postgres://flowmium:flowmium@localhost/flowmium'
74//! export FLOWMIUM_STORE_URL='http://localhost:9000'
75//! export FLOWMIUM_TASK_STORE_URL='http://172.16.238.4:9000'
76//! export FLOWMIUM_BUCKET_NAME='flowmium-test'
77//! export FLOWMIUM_ACCESS_KEY='minio'
78//! export FLOWMIUM_SECRET_KEY='password'
79//! export FLOWMIUM_INIT_CONTAINER_IMAGE='docker.io/shnoo28/flowmium:latest'
80//! export FLOWMIUM_NAMESPACE=default
81//! export KUBECONFIG=./kubeconfig.yaml
82//! cargo run
83//! ```
84
85mod client;
86mod retry;
87mod server;
88mod task;
89
90pub use client::driver as driver_client;
91pub use client::requests;
92pub use server::driver;
93pub use server::event;
94pub use server::executor;
95pub use server::model;
96pub use server::planner;
97pub use server::record;
98pub use server::scheduler;
99pub use server::secrets;