Extract storage, api and web layers into pluggable components
From #3, we probably want:
- slack-ruby-bot-service: just the service parts that starts/stops/restarts/manages a set of teams and bots
- slack-ruby-bot-store: a set of models that give a team storage
- slack-ruby-bot-api: an API for slack button integration and teams
- slack-ruby-bot-web: a Web UI and API to register teams
I recently integrated the concepts from this gem into an existing Rails app. I appreciate your work, @dblock, and all the help you've given me along the way. I was unable to use this gem as-is because I did not want to introduce MongoDB as a dependency.
Here's what I did instead:
- Created
Rails.root.join('lib', 'slack-ruby-bot-server')and copied the correspondingservice.rbandserver.rbfrom this repository into that directory. - Created
Rails.root.join('lib', 'slack-ruby-bot-server', 'ext', 'slack-ruby-client')and copied the corresponding file from this repository into that directory. - Modified
service.rbto remove the mongoid-specific rescue - Added a rake task to run the service.
- Modified
SlackRubyBotService.start!to loop so the rake task that runs it doesn't immediately exit. - Created my own
Teammodel to match the "interface" expected by the server/service classes.
Next up for me:
- Make the service check for new teams to serve.
- Make the service check for teams to stop serving.
For both of these, I don't want the code where those activities take place to interact with the service instance since they are different processes (for me, separate dynos in separate process types on heroku).
I'd love to find a way to contribute my work to this gem. I tend to think reducing its assumptions about storage is a key first step, which is at least part of what this issue is about.
+1 on reducing the assumptions about storage - I think the first step would be to extract a storage interface
I am starting some work to extract the storage interface for use in a private project.
It will be available in my repositories, would appretiate some feedback later.
I am looking to SlackRubyBotServer::App and considering what should or should not continue in this class. Some methods I think that should be removed, because they belong to storage processing, and others related to database, but not exclusively.
I think some methods should be removed from the App class: silence_loggers! check_mongodb_provider! create_indexes!
Others, even being related to database, have something to do with SlackRubyBotServer, like: check_database! mark_teams_active! update_team_name_and_id! migrate_from_single_team! purge_inactive_teams!
Do you have some considerations in this matter?
Take a look at https://github.com/slack-ruby/slack-ruby-bot-server/pull/38, build on top of that.