Consider changing the GDK::Config DSL
I've had remarks about several people who find the current GDK::Config DSL quite confusing and the code behind it in GDK::ConfigSettings hard to understand.
Current state
Currently the DSL is used as something like:
postgresql do |p|
p.port { read!('postgresql_port') || 5432 }
p.replication_user 'gitlab_replication'
p.geo do |g|
g.port { read!('postgresql_geo_port') || 5432 }
g.dir { config.gdk_root.join('postgresql-geo') }
end
end
Proposal
The proposal is to move to something like:
config :postgresql do
integer :port, { read!('postgresql_port') || 5432 }
string :replication_user, 'gitlab_replication'
config :geo do
integer :port, { read!('postgresql_geo_port') || 5432 }
path :dir, { config.gdk_root.join('postgresql-geo') }
end
end
(Some inspiration was taken from https://dry-rb.org/gems/dry-configurable, /ht @nolith)
Each item will be a ConfigSetting instance, but depending on the method used to create it, it might have different type checking.
Advantages
- Less
method_missingmagic. Especially no more arity tricks - Type validation built-in from the start: #659 (closed)
- Easier deprecation of loose files (see !888 (closed) and #658 (closed))
Alternative
If we do not like the different method names, we could also:
config :postgresql do
config :port, type: :integer { read!('postgresql_port') || 5432 }
config :replication_user, type: :string, { 'gitlab_replication' }
config :geo do
config :port, type: :integer, { read!('postgresql_geo_port') || 5432 }
config :dir, type: :path, { config.gdk_root.join('postgresql-geo') }
end
end