Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ formula = "flowrs"
ansi-to-tui = { version = "8.0.1" }
anyhow = { workspace = true }
catppuccin = { workspace = true }
async-trait = { workspace = true }
flowrs-config = { path = "crates/flowrs-config", version = "0.12.1" }
flowrs-airflow = { path = "crates/flowrs-airflow", version = "0.11.1" }
chrono = { workspace = true }
Expand Down
13 changes: 5 additions & 8 deletions src/airflow/client/impls/dag_ops.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use anyhow::Result;
use async_trait::async_trait;

use crate::airflow::client::convert_v1::v1_dag_collection_to_dag_list;
use crate::airflow::client::convert_v2::v2_dag_list_to_dag_list;
use crate::airflow::client::FlowrsClient;
use crate::airflow::model::common::{Dag, DagList};
use crate::airflow::traits::DagOperations;

#[async_trait]
impl DagOperations for FlowrsClient {
async fn list_dags(&self) -> Result<DagList> {
impl FlowrsClient {
pub async fn list_dags(&self) -> Result<DagList> {
match self {
Self::V1(client) => {
let response = client.fetch_dags().await?;
Expand All @@ -22,21 +19,21 @@ impl DagOperations for FlowrsClient {
}
}

async fn toggle_dag(&self, dag_id: &str, is_paused: bool) -> Result<()> {
pub async fn toggle_dag(&self, dag_id: &str, is_paused: bool) -> Result<()> {
match self {
Self::V1(client) => client.patch_dag_pause(dag_id, is_paused).await,
Self::V2(client) => client.patch_dag_pause(dag_id, is_paused).await,
}
}

async fn get_dag_code(&self, dag: &Dag) -> Result<String> {
pub async fn get_dag_code(&self, dag: &Dag) -> Result<String> {
match self {
Self::V1(client) => client.fetch_dag_code(&dag.file_token).await,
Self::V2(client) => client.fetch_dag_code(&dag.dag_id).await,
}
}

async fn get_dag_params(&self, dag_id: &str) -> Result<Option<serde_json::Value>> {
pub async fn get_dag_params(&self, dag_id: &str) -> Result<Option<serde_json::Value>> {
match self {
Self::V1(client) => client.fetch_dag_params(dag_id).await,
Self::V2(client) => client.fetch_dag_params(dag_id).await,
Expand Down
13 changes: 5 additions & 8 deletions src/airflow/client/impls/dagrun_ops.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use anyhow::Result;
use async_trait::async_trait;

use crate::airflow::client::convert_v1::v1_dagrun_collection_to_list;
use crate::airflow::client::convert_v2::v2_dagrun_list_to_list;
use crate::airflow::client::FlowrsClient;
use crate::airflow::model::common::DagRunList;
use crate::airflow::traits::DagRunOperations;

#[async_trait]
impl DagRunOperations for FlowrsClient {
async fn list_dagruns(&self, dag_id: &str) -> Result<DagRunList> {
impl FlowrsClient {
pub async fn list_dagruns(&self, dag_id: &str) -> Result<DagRunList> {
match self {
Self::V1(client) => {
let response = client.fetch_dagruns(dag_id).await?;
Expand All @@ -22,21 +19,21 @@ impl DagRunOperations for FlowrsClient {
}
}

async fn mark_dag_run(&self, dag_id: &str, dag_run_id: &str, status: &str) -> Result<()> {
pub async fn mark_dag_run(&self, dag_id: &str, dag_run_id: &str, status: &str) -> Result<()> {
match self {
Self::V1(client) => client.patch_dag_run(dag_id, dag_run_id, status).await,
Self::V2(client) => client.patch_dag_run(dag_id, dag_run_id, status).await,
}
}

async fn clear_dagrun(&self, dag_id: &str, dag_run_id: &str) -> Result<()> {
pub async fn clear_dagrun(&self, dag_id: &str, dag_run_id: &str) -> Result<()> {
match self {
Self::V1(client) => client.post_clear_dagrun(dag_id, dag_run_id).await,
Self::V2(client) => client.post_clear_dagrun(dag_id, dag_run_id).await,
}
}

async fn trigger_dag_run(
pub async fn trigger_dag_run(
&self,
dag_id: &str,
logical_date: Option<&str>,
Expand Down
7 changes: 2 additions & 5 deletions src/airflow/client/impls/dagstats_ops.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use anyhow::Result;
use async_trait::async_trait;

use crate::airflow::client::convert_v1::v1_dagstats_to_response;
use crate::airflow::client::convert_v2::v2_dagstats_to_response;
use crate::airflow::client::FlowrsClient;
use crate::airflow::model::common::DagStatsResponse;
use crate::airflow::traits::DagStatsOperations;

#[async_trait]
impl DagStatsOperations for FlowrsClient {
async fn get_dag_stats(&self, dag_ids: Vec<&str>) -> Result<DagStatsResponse> {
impl FlowrsClient {
pub async fn get_dag_stats(&self, dag_ids: Vec<&str>) -> Result<DagStatsResponse> {
match self {
Self::V1(client) => {
let response = client.fetch_dag_stats(dag_ids).await?;
Expand Down
7 changes: 2 additions & 5 deletions src/airflow/client/impls/log_ops.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use anyhow::Result;
use async_trait::async_trait;

use crate::airflow::client::convert_v1::v1_log_to_log;
use crate::airflow::client::convert_v2::v2_log_to_log;
use crate::airflow::client::FlowrsClient;
use crate::airflow::model::common::Log;
use crate::airflow::traits::LogOperations;

#[async_trait]
impl LogOperations for FlowrsClient {
async fn get_task_logs(
impl FlowrsClient {
pub async fn get_task_logs(
&self,
dag_id: &str,
dag_run_id: &str,
Expand Down
7 changes: 2 additions & 5 deletions src/airflow/client/impls/task_ops.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use anyhow::Result;
use async_trait::async_trait;

use crate::airflow::client::convert_v1::v1_task_collection_to_list;
use crate::airflow::client::convert_v2::v2_task_collection_to_list;
use crate::airflow::client::FlowrsClient;
use crate::airflow::model::common::TaskList;
use crate::airflow::traits::TaskOperations;

#[async_trait]
impl TaskOperations for FlowrsClient {
async fn list_tasks(&self, dag_id: &str) -> Result<TaskList> {
impl FlowrsClient {
pub async fn list_tasks(&self, dag_id: &str) -> Result<TaskList> {
match self {
Self::V1(client) => {
let response = client.fetch_tasks(dag_id).await?;
Expand Down
13 changes: 5 additions & 8 deletions src/airflow/client/impls/taskinstance_ops.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use anyhow::Result;
use async_trait::async_trait;

use crate::airflow::client::convert_v1::{
v1_task_instance_collection_to_list, v1_task_instance_try_to_gantt,
Expand All @@ -9,11 +8,9 @@ use crate::airflow::client::convert_v2::{
};
use crate::airflow::client::FlowrsClient;
use crate::airflow::model::common::{TaskInstanceList, TaskTryGantt};
use crate::airflow::traits::TaskInstanceOperations;

#[async_trait]
impl TaskInstanceOperations for FlowrsClient {
async fn list_task_instances(
impl FlowrsClient {
pub async fn list_task_instances(
&self,
dag_id: &str,
dag_run_id: &str,
Expand All @@ -30,7 +27,7 @@ impl TaskInstanceOperations for FlowrsClient {
}
}

async fn list_task_instance_tries(
pub async fn list_task_instance_tries(
&self,
dag_id: &str,
dag_run_id: &str,
Expand Down Expand Up @@ -60,7 +57,7 @@ impl TaskInstanceOperations for FlowrsClient {
}
}

async fn mark_task_instance(
pub async fn mark_task_instance(
&self,
dag_id: &str,
dag_run_id: &str,
Expand All @@ -81,7 +78,7 @@ impl TaskInstanceOperations for FlowrsClient {
}
}

async fn clear_task_instance(
pub async fn clear_task_instance(
&self,
dag_id: &str,
dag_run_id: &str,
Expand Down
7 changes: 3 additions & 4 deletions src/airflow/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ use flowrs_airflow::client::{BaseClient, V1Client, V2Client};
use flowrs_airflow::{AirflowConfig, AirflowVersion};

use crate::airflow::model::common::OpenItem;
use crate::airflow::traits::AirflowClient;

use open_url::{build_v1_open_url, build_v2_open_url};

/// Wrapper enum that owns a versioned Airflow HTTP client and implements the TUI trait layer.
/// Wrapper enum that owns a versioned Airflow HTTP client and exposes the TUI-facing operations.
#[derive(Debug)]
pub enum FlowrsClient {
V1(V1Client),
Expand All @@ -31,8 +30,8 @@ impl FlowrsClient {
}
}

impl AirflowClient for FlowrsClient {
fn build_open_url(&self, item: &OpenItem) -> Result<String> {
impl FlowrsClient {
pub fn build_open_url(&self, item: &OpenItem) -> Result<String> {
match self {
Self::V1(client) => build_v1_open_url(client.endpoint(), item),
Self::V2(client) => build_v2_open_url(client.endpoint(), item),
Expand Down
1 change: 0 additions & 1 deletion src/airflow/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod client;
pub mod graph;
pub mod model;
pub mod traits;
20 changes: 0 additions & 20 deletions src/airflow/traits/dag.rs

This file was deleted.

25 changes: 0 additions & 25 deletions src/airflow/traits/dagrun.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/airflow/traits/dagstats.rs

This file was deleted.

17 changes: 0 additions & 17 deletions src/airflow/traits/log.rs

This file was deleted.

37 changes: 0 additions & 37 deletions src/airflow/traits/mod.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/airflow/traits/task.rs

This file was deleted.

37 changes: 0 additions & 37 deletions src/airflow/traits/taskinstance.rs

This file was deleted.

Loading
Loading