Skip to content

Automatic configuration schema loading from database#525

Merged
mmastrac merged 2 commits intogeldata:masterfrom
mmastrac:gel-config
Aug 21, 2025
Merged

Automatic configuration schema loading from database#525
mmastrac merged 2 commits intogeldata:masterfrom
mmastrac:gel-config

Conversation

@mmastrac
Copy link
Contributor

@mmastrac mmastrac commented Aug 7, 2025

Implements a DB schema to config generator. Since we cannot guarantee DB introspection in versions 6 and lower, we hard-code a config schema JSON blob as a fallback.

This library can also generate valid EdgeQL DDL for configuration changes.

Live DB schema introspection will be handled in the CLI.

TODO:

  • Compress JSON?
  • Docs
  • Error tests

Example:

[branch.config]

# timeouts
session_idle_transaction_timeout     = "30 seconds"
query_execution_timeout              = "1 minute"

[instance.config]
http_max_connections                 = 100

[branch.config."cfg::Config"]
allow_user_specified_id              = true

[[branch.config.email_providers]]
_tname                = "cfg::SMTPProviderConfig"
name                  = "mailtrap-sandbox"
port                  = 2525
timeout_per_email     = "5 minutes"
timeout_per_attempt   = "1 minute"
validate_certs        = false

[[branch.config.'cfg::SMTPProviderConfig']]
port                  = 2525
name                  = "some-other-smtp-provider"
timeout_per_email     = "5 minutes"
timeout_per_attempt   = "1 minute"
validate_certs        = false


[[instance.config.auth]]
priority = 100
user = ["gel"]
method = { _tname = "cfg::JWT", transports = ["HTTP"] }

[[instance.config.auth]]
priority = 200
user = ["admin", "gel"]
method = { _tname = "cfg::SCRAM", transports = ["TCP", "HTTP"] }

Output:

configure instance set http_max_connections := <std::int64>100;
configure instance reset auth;
configure instance insert cfg::Auth {
    priority := <std::int64>100,
    user := {<std::str>'gel'},
    method := (insert cfg::JWT {
        transports := {<cfg::ConnectionTransport>'HTTP'}
    })
};
configure instance insert cfg::Auth {
    priority := <std::int64>200,
    user := {<std::str>'admin', <std::str>'gel'},
    method := (insert cfg::SCRAM {
        transports := {<cfg::ConnectionTransport>'TCP', <cfg::ConnectionTransport>'HTTP'}
    })
};
configure current database set allow_user_specified_id := <std::bool>true;
configure current database set query_execution_timeout := <std::duration>'1 minute';
configure current database set session_idle_transaction_timeout := <std::duration>'30 seconds';
configure current database reset email_providers;
configure current database insert cfg::SMTPProviderConfig {
    name := <std::str>'some-other-smtp-provider',
    port := <std::int32>2525,
    validate_certs := <std::bool>false,
    timeout_per_email := <std::duration>'5 minutes',
    timeout_per_attempt := <std::duration>'1 minute'
};
configure current database insert cfg::SMTPProviderConfig {
    name := <std::str>'mailtrap-sandbox',
    port := <std::int32>2525,
    validate_certs := <std::bool>false,
    timeout_per_email := <std::duration>'5 minutes',
    timeout_per_attempt := <std::duration>'1 minute'
};

@mmastrac mmastrac changed the title WIP: automatic configuration from database Automatic configuration schema loading from database Aug 8, 2025
@mmastrac mmastrac requested review from aljazerzen and fantix August 8, 2025 18:15
@mmastrac mmastrac merged commit 75a6f76 into geldata:master Aug 21, 2025
13 checks passed
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

Successfully merging this pull request may close these issues.

1 participant

Comments