-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: connect batch etl to trieve
- Loading branch information
Showing
36 changed files
with
2,147 additions
and
618 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
DROP TABLE IF EXISTS inputs; | ||
DROP TABLE IF EXISTS jobs; | ||
DROP TABLE IF EXISTS schemas; | ||
DROP TABLE IF EXISTS schemas; | ||
DROP TABLE IF EXISTS batches; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
url = "http://localhost:8123" | ||
url = "http://localhost:8124" | ||
user = "clickhouse" | ||
password = "password" | ||
database = "default" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use batch_etl::operators::{ | ||
batch::{get_batch_output, get_pending_batches}, | ||
job::send_webhook, | ||
}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
dotenvy::dotenv().ok(); | ||
env_logger::builder() | ||
.target(env_logger::Target::Stdout) | ||
.filter_level(log::LevelFilter::Info) | ||
.init(); | ||
|
||
let clickhouse_client = clickhouse::Client::default() | ||
.with_url(std::env::var("CLICKHOUSE_URL").unwrap_or("http://localhost:8123".to_string())) | ||
.with_user(std::env::var("CLICKHOUSE_USER").unwrap_or("default".to_string())) | ||
.with_password(std::env::var("CLICKHOUSE_PASSWORD").unwrap_or("".to_string())) | ||
.with_database(std::env::var("CLICKHOUSE_DATABASE").unwrap_or("default".to_string())) | ||
.with_option("async_insert", "1") | ||
.with_option("wait_for_async_insert", "0"); | ||
|
||
let pending_batches = get_pending_batches(&clickhouse_client).await.unwrap(); | ||
log::info!("Pending batches: {:?}", pending_batches); | ||
|
||
for (batch, id, webhook_url) in pending_batches { | ||
log::info!("Processing batch: {:?}", batch); | ||
let batch_url = get_batch_output(&clickhouse_client, batch).await.unwrap(); | ||
log::info!("Batch URL: {:?}", batch_url); | ||
if let Some(webhook_url) = webhook_url { | ||
if let Some(batch_url) = batch_url { | ||
log::info!("Sending webhook to: {:?}", webhook_url); | ||
send_webhook(webhook_url, id, batch_url).await.unwrap(); | ||
} | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.