fermyon / spin

Spin is the open source developer tool for building and running serverless applications powered by WebAssembly.
https://developer.fermyon.com/spin
Apache License 2.0
5.22k stars 247 forks source link

Connecting using a simple postgresql url shouldn't be this convoluted #2708

Open chokosabe opened 2 months ago

chokosabe commented 2 months ago

Connecting via postgresql url (localhost) currently looks like this:

setting a variable: postgresql://postgres:postgres@localhost:5433 setting allowed_outbound_hosts = ["postgres://localhost:5433"]

in code: pg:Connection(postgresql_url + db_name)

Ideally you set a single variable and you can use it within the app. We are seemingly parsing and expecting differing representations of the same value (in multiple places) for no good reason.

Also, none of this behaviour is documented anywhere. The docs as they currently are are misleading.

rylev commented 2 months ago

Thanks for the feedback! Question: it seems like you are setting a variable in the spin.toml manifest, but not using it in your code? There's no need to set the variable if you won't be using inside the application code. Perhaps I'm misunderstanding what the issue is, so any additional information would be helpful.

chokosabe commented 2 months ago

Thanks for the feedback! Question: it seems like you are setting a variable in the spin.toml manifest, but not using it in your code? There's no need to set the variable if you won't be using inside the application code. Perhaps I'm misunderstanding what the issue is, so any additional information would be helpful.

Whether or not its used is irrelevant. You should still be able to set it. More importantly is that it can take up to 3 different forms to set what should be a single value. Also, most importantly none of this is anywhere in the docs. Half a day was lost just working this out. In the case of postgresql, I think the docs were misleading. The errors that are generated should make sense as well.