Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config to disable the default File loader #12

Closed
theory opened this issue Apr 12, 2024 · 3 comments
Closed

Add config to disable the default File loader #12

theory opened this issue Apr 12, 2024 · 3 comments

Comments

@theory
Copy link

theory commented Apr 12, 2024

I'm working on a postgres extension using boon, and I'd like to prevent it from loading the default file loader. Right now I'm replacing it with a no-op loader, but it'd be nice to have a feature to enable to just prevent it from being compiled. Something to complement the cfg(not(target_arch = "wasm32")) macro, having the same behavior but not specific to wasm.

theory added a commit to tembo-io/pg-jsonschema-boon that referenced this issue Apr 12, 2024
Replace it with a no-op loader. Add tests to be sure it actually does
its thing; without it added to the compiler, the test returns a file not
found error! Long-term it'd be nice to prevent it from being compiled at
all; see santhosh-tekuri/boon#12 for the feature request.

While at it, update the `error!()` and `info!()` calls to include the
failure reason. The magic `:#` suffix in the format does it.
theory added a commit to tembo-io/pg-jsonschema-boon that referenced this issue Apr 12, 2024
Replace the boon file loader with a no-op loader. Add tests to be sure
it actually does its thing; without it added to the compiler, the test
returns a file not found error! Long-term it'd be nice to prevent it
from being compiled at all; see santhosh-tekuri/boon#12 for the feature
request.

While at it, update the `error!()` and `info!()` calls to include the
failure reason. The magic `:#` suffix in the format does it.

Spotted while adding regression tests, also included here and run
through PGXS's `installcheck` make target. Go ahead and start the
apt-get-installed cluster in the `lint-and-test.yml` workflow and use it
for `make installcheck`.
@santhosh-tekuri
Copy link
Owner

fixed in da002ca

Compiler.register_url_loader(...) is removed. now Compiler.use_loader(...) added

FileLoader is now made public.
new struct SchemeUrlLoader added which supports previous style url scheme based loaders

see tests/examples.rs for changes in usages

@theory
Copy link
Author

theory commented May 23, 2024

Nice. So if I want it to have no loaders at all, is there something I can pass to use_loader() so that FileLoader isn't loaded?

@santhosh-tekuri
Copy link
Owner

you can use SchemeUrlLoader:

let loader = SchemeUrlLoader::new();
compiler.useLoader(Box::new(loader));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants