backburner icon indicating copy to clipboard operation
backburner copied to clipboard

Move configuration to yml file.

Open arrowcircle opened this issue 11 years ago • 9 comments

Is it possible, to move this block to yaml file?

Backburner.configure do |config|
  ...
end

Its needed, when you have different configurations for development, staging and production. Or is there any other convenient way to split configuration?

arrowcircle avatar Jun 04 '13 20:06 arrowcircle

Yes you could, I actually do have mine in a YML file for my projects:

BACKBURNER_CONFIG = YAML.load_file("path/to/yml")[Padrino.env]
Backburner.configure do |config|
  config.something = BACKBURNER_CONFIG['something']
end

Since Backburner can be used from sinatra, rails and padrino, I like to leave this up to the user's discretion.

nesquena avatar Jun 04 '13 20:06 nesquena

Any sample yaml files with all available options? Or they are named exactly as in ruby?

arrowcircle avatar Jun 04 '13 20:06 arrowcircle

Yep, you got it named based on the ruby:

---
beanstalk_url: "beanstalk://127.0.0.1"
tube_namespace: "some-app-production"
max_job_retries: 3

etc. You can even do something like:

Backburner.configure do |config|
  BACKBURNER_CONFIG.keys.each do |k, v|
    config.send("#{k}=", v)
  end
end

nesquena avatar Jun 04 '13 20:06 nesquena

I think it's not very convenient way to load config. Maybe, it's better to make something like sidekiq -C config file path? Also, way with send is not good I think because of send. Is it possible to pass pid path to config?

arrowcircle avatar Jun 04 '13 20:06 arrowcircle

Yeah I see your point, I like the idea of having a -C flag passable into the bin to configure the settings. Will do for a future version or accept a pull request.

nesquena avatar Jun 04 '13 20:06 nesquena

Why not a .rb configuration file like unicorn? That way one can still have the ability to do some preprocessing, load things from ENV etc.

Just a simple YML file is too restrictive.

rewritten avatar Nov 14 '13 15:11 rewritten

Not a bad point, it could be a .rb configuration file but then how different is that from the configure block we have now? What would you propose for the DSL?

nesquena avatar Nov 15 '13 09:11 nesquena

Exactly... it would bear no difference at all. The DSL would be the same, it's only a matter of loading the specified file at the correct moment. It would be similar to having different configurations in config/environments/*.rb files, but using a separate file. And not having to depend on rails environment magic.

rewritten avatar Nov 15 '13 09:11 rewritten

Ah I see, yeah that makes sense.

nesquena avatar Nov 15 '13 09:11 nesquena