We decided that the goal for v2.0.0.alpha3 will be to finalize the application template code.
That means to cleanup application template code, improve it with features, but also extract parts of it in Hanami gems.
This forum topic should be used to share feedback regarding the application template, so we can openly decide which work shall be done for alpha3.
Each decision will result into a Trello ticket, which will be taken from any of us into the development process.
For each implemented ticket (into Hanami gems), we must update the application template to reflect the changes from the framework.
Please provide your feedback here.
In order to make feedback process easier, please create a separated comment for each file in the application template that you would see to be changed. Use threads to discuss each feedback.
Consider to introduce stop block in Dry::System.register_bootable so the informations to tear down a component are local to it:
Hanami.container.register :persistence, namespace: true do |container|
init { ... }
start { ... }
stop do
rom = container["persistence.rom"]
rom&.disconnect
end
end
Consider to introduce Hanami.reboot (or Hanami.application.reboot) which will loop thru the initialised components and invoke stop and then start. This will make Puma’s before_fork much simpler
We should consider to implement environment block for selectively setup configurations:
module MyApp
class Application < Hanami::Application
config.environment(:test) do
# activate this block only if Hanami.env == :test
config.logging = { ... }
end
end
end
I was thinking about shipping rom (the gem) with built-in system components. So then, in hanami, you’d be able to just do something like this:
# config/boot/persistence.rb
Hanami.application.register_bootable(:persistence, from: :rom) do |container|
after(:init) do
container["rom.config"].plugin(:sql, relations: :auto_restrictions)
end
end
In the most simplistic use-case, this would just work too:
require "hanami"
module Bookshelf
class Application < Hanami::Application
# this would result in having container["rom"] registered
# based on DATABASE_URL setting
register_bootable(:persistence, from: :rom)
end
end
I also need to figure out how to pre-configure instrumentation, that’s a bit tricky because notifications object that’s used for instrumentation is provided by hanami.
This will go away I’ll be adding support for pre-configured structs directly to rom core. BTW I’m for renaming Entity => Struct and sticking to it. This can be of course configurable, but I would vote for using Struct as the default name because Entity can be confused with stuff from DDD where identity is based on a key value (IIRC).