mosquito-cr / mosquito

A background task runner for crystal applications supporting periodic (CRON) and manually queued jobs
MIT License
227 stars 24 forks source link

Allow redis url to be configured without env #49

Closed watzon closed 4 years ago

watzon commented 4 years ago

Idk how you feel about this. Personally I feel like, since so many things are being done at the class level rather than the instance level anyway (i.e. using Class.instance everywhere), it would make sense to have a Config module which holds configuration options. I'd be happy to add such a thing and update this PR, but for now I've just added a class property connection_url to the Redis class which defaults to ENV["REDIS_URL"].

The benefit of this approach is that people can set their own environment variable if they want, or load the configuration option in another way. For example:

# config.cr
require "mosquito"

Mosquito::Redis.connection_url = "redis://127.0.0.1:6379"

spawn do
  Mosquito::Runner.start
end

This would close #3

watzon commented 4 years ago

I was actually thinking about using Habitat, would you be opposed to that? I can update the PR later.

robacarp commented 4 years ago

@watzon absolutely! That would be a fantastic upgrade. :)

watzon commented 4 years ago

Ok cool, I'll see what I can do :)

watzon commented 4 years ago

Are there other configuration options that it would make sense to have there besides the redis url?

robacarp commented 4 years ago

@watzon this completely dropped off my radar. One out of scope addition that needs to be cleaned up and I'd be happy to merge.

watzon commented 4 years ago

Awesome, thanks 😊