go-spatial / tegola

Tegola is a Mapbox Vector Tile server written in Go
http://tegola.io/
MIT License
1.29k stars 196 forks source link

Support conninfo string to connect to postgis provider #774

Closed flacombe closed 2 years ago

flacombe commented 3 years ago

Dear maintainers,

Currently, postgis provider can only be reached with several arguments like host, port, dbname, etc... while libpq actually offers a more concise way to connect to a postgresql database. Unless I skip some existing issue, this hasn't been asked for yet.

See 33.1.1 here: https://www.postgresql.org/docs/13/libpq-connect.html

Example:

[[providers]]
name = "test_postgis"   # provider name is referenced from map layers
type = "postgis"        # the type of data provider.
uri = "postgres://tegola:tegolapwd@localhost:5432/tegola"
srid = 3857             # The default srid for this provider. If not provided it will be WebMercator (3857)

instead of

[[providers]]
name = "test_postgis"   # provider name is referenced from map layers
type = "postgis"        # the type of data provider.
host = "localhost"      # postgis database host
port = 5432             # postgis database port
database = "tegola"     # postgis database name
user = "tegola"         # postgis database user
password = "tegolapwd"           # postgis database password
srid = 3857             # The default srid for this provider. If not provided it will be WebMercator (3857)

It would be great to add this support in Tegola configuration please :)

Many thanks in advance

ARolek commented 3 years ago

I'm all for this support, we just need someone to run with plumbing this trough. We have a couple of related issues: #370 and #125. Would you be interested in working on this feature?

It might make sense to tackle this one along with upgrading the pgx driver so we can squash #748 at the same time.

flacombe commented 3 years ago

Thank you for this acknowledgment

Even if I wish to get involved in opensource projects I use, there are two main challenges I have to tackle prior to bring this to Tegola:

That's barely possible for me to take this time now, dealing with my workload. Wait and see

ARolek commented 3 years ago

No worries! I figured I would throw out the offer in case you were interested in sending in some code. I'm always happy to help.

wielski commented 2 years ago

It's also very important to make this feature bacause of in current implementation it's impossible to use multiple hosts for replication. PostgtreSQL allows to use multiple hosts like this:

postgresql://user:password@host1.example.com:1234,host2.example.com:1234,host3.example.com:1324?options
ARolek commented 2 years ago

I think it would make sense to implement this after the pgx v4 upgrade is addressed (#748)

ARolek commented 2 years ago

@flacombe and @wielski This is now in the v0.15.x branch (thanks to @iwpnd!) if you would like to give it a test.