Where to put scripts and classes for external processes?

I have an object (EventRunner) whose sole purpose is to listen on a Redis pub/sub channel and enqueue a Resque job when a certain message is received on the channel. The EventRunner is instantiated and executed as a separate process in parallel with the Hanami process.

Questions:

  • Would EventRunner be considered a service object or something else?
  • Where would be the best place to put the event_runner.rb class file and the executable script which instantiates it?
  • I currently have the class file in PROJECT_ROOT/lib/backend/services/ (parallel with entities, etc.). The script is in PROJECT_ROOT/script/. Are these appropriate locations, or should they be placed elsewhere?

Hi Earle and welcome!

Yes, both the locations for the classes and the scripts look good to me.
Please remember that with Hanami you can organize the lib/ directory according to your needs. There is no magic involved there. Only the code generators will keep adding new entities and repositories under lib/bookshelf/entities and lib/bookshelf/repositories.

:cherry_blossom:

@jodosha Great. Thanks for the feedback.

1 Like