supabase / pg_replicate

Build Postgres replication apps in Rust
Apache License 2.0
560 stars 19 forks source link

Put sinks behind feature flags #26

Closed funlennysub closed 1 month ago

funlennysub commented 1 month ago

What kind of change does this PR introduce?

Implement #25

funlennysub commented 1 month ago

Currently if you run cargo test in root directory with no features it will complain about examples not having bigquery, I'm not sure how to make it only compile the example if you have the feature enabled

imor commented 1 month ago

Currently if you run cargo test in root directory with no features it will complain about examples not having bigquery, I'm not sure how to make it only compile the example if you have the feature enabled

Adding the following to the pg_replicate's Cargo.toml should fix this:

[[example]]
name = "bigquery"
required-features = ["bigquery"]

[[example]]
name = "duckdb"
required-features = ["duckdb"]
funlennysub commented 1 month ago

Will try later. Also, do you want me to test code twice, with and without features?

imor commented 1 month ago

do you want me to test code twice, with and without features?

If you mean the two separate steps "Run api tests" and "Run non-api tests", they are separate because api tests need a running Postgres, while the others don't. Leave them as they are now (i.e. --all-features should be only on "Run non-api tests").

funlennysub commented 1 month ago

I mostly meant the non-api tests to be ran with --no-default-features and --all-features

imor commented 1 month ago

cargo test --workspace --all-features --exclude api should be fine for now.

funlennysub commented 1 month ago

This shouldn't be a problem but if you run cargo run --example bigquery from repository root, it will run the example without asking for a feature, unlike duckdb, but if ran from pg_replicate crate it won't run and say you need a feature enabled. Other than that everything works as expected.

imor commented 1 month ago

That's a bit weird. Maybe a cargo quirk. Not a big deal though, if we run the example with cargo run -p pg_replicate --example <example_name> --features="<example_name>" it works fine. I'll update the README with this. Merging it now. Thanks for the PR.