Generator for providers

With ROM being included and relying heavily on the providers concept (re: the guides V2.1: Building a web app | Hanami Guides), I feel like it would be helpful to have a provider generator, maybe even with the option to generate specifically a ‘persistence’ style provider if it can be made generalized.

Any thoughts on this?

I think providers are too broad of a concept to provide (heh) a meaningful template for them. I mean provider for redis, postgres and Stripe would be very, very different from each other.
I think the boilerplate could be something like:

Hanami.app.register_provider :name_given_in_command, namespace: [true_or_false_based_on_argument_but_true_by_default] do
  prepare do
    # your preparation
  end

  start do
    # your start code
  end

  stop do
    # your cleanup
  end
end

And it would put the file in the correct spot, but all providers live in the same place anyway, so that is not that much of a help. I dunno, maybe you see some more ideas for it, but I can’t think of any universal CLI that would be actually useful in building templates for providers.

As for persistence providers, that won’t be necessary since 2.2.0 is going to include persistence by default

1 Like

thanks for the response @krzykamil!

i follow your logic and agree. i was mostly concerned about persistence, but since this post have become more familiar with 2.2 and how persistence will be integrated in apps going forward. now wielding this knowledge - agreed there isn’t really a use case. thanks for the input though!

I think adding a provider generator would be useful at some point, but it’s low priority for now, since it’s not a super common activity and they’re simple enough to write manually.

1 Like

Would it be easy to write a command for a third party app to generate it’s own bootstrap provider in config/providers/third_party_provider.rb ?