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

Rework Config file structure... take 2 #550

Open
nyurik opened this issue Jan 9, 2023 · 2 comments
Open

Rework Config file structure... take 2 #550

nyurik opened this issue Jan 9, 2023 · 2 comments

Comments

@nyurik
Copy link
Member

nyurik commented Jan 9, 2023

It seems config is still fairly convoluted, and may need some cleanup... Another proposal:

server:
  keep-alive: 75
  listen-addresses: '0.0.0.0:3000'
  worker-processes: 8

# for now connections can only support postgres.
# File sources are either auto-published or listed directly in sources 
connections:
  pg1:
    # connection type is detected by the connection field
    connection: postgres://...
    default-srid: ...
    disable-bounds: ...
    pool-size: ...
    maxzoom: 10  # some values can set defaults for all sources that use this connection

# These define how sources will be auto-discovered from connections (PG) or from directories
auto-publish:
  postgres:
    - connection: pg1
      from-schemas:
        - public
        - my_schema
      tables:
        id-format: '{schema}.{table}.{column}'
      functions:
        id-format: '{schema}.{function}'
    - connection: pg2
      # ...
  mbtiles:
    - /dir/path
  pmtiles:
    - /dir/path
    - path: /dir/path
      minzoom: 0
      maxzoom: 10

# These are the "hard-coded" tile sources from different connections
sources:
  # source type is detected by filename extension
  src1: data.mbtiles
  src2:
    # publish pmtiles with extra config
    file: path/to/file.pmtiles
    maxzoom: 10
  src3:
    # publish a postgres table
    # source type is detected by the connection field referencing above connection object
    connection: pg1
    schema: foo
    table: bar
  src4:
    # Publish a postgres function
    connection: pg1
    schema: foo
    function: bar

Additionally, there are some settings to allow override generated tilejson. Any of these values can be added to any of the sources, connections, and auto-publish sections.

minzoom: 0
maxzoom: 10
name: "source name"
attribution: "source attribution"
description: "source description"
legend: "source legend"
bounds: [-10, -20, 30, 40]
center: [10.2, 34.5, 3]
version: "1.42"
@nyurik
Copy link
Member Author

nyurik commented Jan 9, 2023

Related topic is how to parse this config with serde enum - it could either be untagged, in which case user may see unexpected errors if the config value cannot be matched perfectly, or we could do it "by hand":

  • parse into objects like sources: HashMap<String, Value>
  • manually test it, e.g. sources.get("connection") is a string and starts with "postgres://" => treat as postgres.

@nyurik
Copy link
Member Author

nyurik commented Jan 12, 2023

I tried hacking on this implementation, and one already apparent annoyance is the auto-publish separation for pg:

connections:
  pg1:
    connection: postgres://...

auto-publish:
  postgres:
    - connection: pg1

The issues with the above:

  • multiple auto-publish for one connection
  • auto-publish is separate from the connection, which is kinda weird, but is inline with other sources that do not have connections (mbtiles/pmtiles)
  • duplicate line connection: with different meaning, and kinda verbose

Possible but non-ideal solutions:

connections:
  pg1:
    connection: postgres://...

auto-publish:
  postgres:
    pg1: ...  # the key here must match the key in connections. This is bad because other auto-publish types are lists
connections:
  pg1:
    connection: postgres://...
    auto-publish: ...  # just like before -- autopublish is part of the connection. This is bad because other types like mbtiles/pmtiles do not have connections

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

1 participant