• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / etl / 15885763648

25 Jun 2025 07:49PM UTC coverage: 60.073% (-1.4%) from 61.443%
15885763648

Pull #152

github

web-flow
Merge 2b95001e0 into 9f0201c2d
Pull Request #152: feat: add postgres state store to allow state to be persisted to the source db

81 of 313 new or added lines in 16 files covered. (25.88%)

29 existing lines in 8 files now uncovered.

5576 of 9282 relevant lines covered (60.07%)

27.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/api/src/main.rs
1
use std::env;
2

3
use anyhow::anyhow;
4
use api::{config::ApiConfig, startup::Application};
5
use config::load_config;
6
use postgres::sqlx::config::PgConnectionConfig;
7
use telemetry::init_tracing;
8
use tracing::{error, info};
9

10
#[actix_web::main]
11
pub async fn main() -> anyhow::Result<()> {
12
    let app_name = env!("CARGO_BIN_NAME");
13

14
    // We pass emit_on_span_close = true to emit logs on span close
15
    // for the api because it is a web server, and we need to emit logs
16
    // for every closing request. This is a bit of a hack, but it works
17
    // for now. Ideally the tracing middleware should emit a log on
18
    // request end, but it doesn't do that yet.
19
    let _log_flusher = init_tracing(app_name, true)?;
20

21
    let mut args = env::args();
22
    match args.len() {
23
        // Run the application server
24
        1 => {
25
            let config = load_config::<ApiConfig>()?;
26
            log_pg_connection_config(&config.database);
27
            let application = Application::build(config.clone()).await?;
28
            application.run_until_stopped().await?;
29
        }
30
        // Handle single command commands
31
        2 => {
32
            let command = args.nth(1).unwrap();
33
            match command.as_str() {
34
                "migrate" => {
35
                    let config = load_config::<PgConnectionConfig>()?;
36
                    log_pg_connection_config(&config);
37
                    Application::migrate_database(config).await?;
38
                    info!("database migrated successfully");
39
                }
40
                _ => {
41
                    let message = format!("invalid command: {command}");
42
                    error!("{message}");
43
                    return Err(anyhow!(message));
44
                }
45
            }
46
        }
47
        _ => {
48
            let message = "invalid number of command line arguments";
49
            error!("{message}");
50
            return Err(anyhow!(message));
51
        }
52
    }
53

54
    Ok(())
55
}
56

57
fn log_pg_connection_config(config: &PgConnectionConfig) {
×
58
    info!(
×
59
        host = config.host,
60
        port = config.port,
61
        dbname = config.name,
62
        username = config.username,
NEW
63
        ssl_mode = config.tls_config.ssl_mode.to_string(),
×
64
        "pg database options",
×
65
    );
66
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc