The old offset calculation was always one second off: ```ruby irb(main):049:0> offset = ((Time.now + 2) - Time.now) => 1.999996 irb(main):004:0> offset.to_i => 1 ``` Report in rails/rails@40ff508#commitcomment-10860316
Users which are still running Ruby `1.8.7` can use previous released versions of QC.
Forwarding every message results in confusing `NoMethodError`s.
This is my first stab at decoupling the configuration from constants. The work is not finished but far enough to be shared. I did deprecate the old `QC::XYZ` constants in favor of methods on `QC`. The rest of the changes should not be noticed from a user perspective. I added good test coverage for all operations we performed on constant assignment. Other than that I added a little feature here and there. The individual commit messages go into more detail about that. There is some more work involved to move `default_conn_adapter`. I also want to provide an API to configure QC via Ruby. Lastly I think we should deprecate `QC.queue` formerly `QC::QUEUE`. It's overlapping with `QC.default_queue` and easy to confuse with `QC.queues`. Feedback is appreciated. /cc @jipiboily
The big picture is to decouple QC's configuration from env vars. They will still serve as primary source of configuration. However, we should allow configuration through Ruby code as well.
I noticed some random build failures when `worker_test.rb#test_init_worker_with_arg` ran before `QC.default_conn_adapter` was called. The issue was that the `with_database` helper mingled with env vars before remembering the `QC.default_conn_adapter`. In the case of `test_init_worker_with_arg` an invalid environment was setup. This resulted in an attempt to connect to that invalid database. ``` 1) Error: WorkerTest#test_init_worker_with_arg: PG::ConnectionBad: FATAL: database "invalid" does not exist /Users/senny/Projects/queue_classic/lib/queue_classic/conn_adapter.rb:73:in `initialize' /Users/senny/Projects/queue_classic/lib/queue_classic/conn_adapter.rb:73:in `new' /Users/senny/Projects/queue_classic/lib/queue_classic/conn_adapter.rb:73:in `establish_new' /Users/senny/Projects/queue_classic/lib/queue_classic/conn_adapter.rb:9:in `initialize' /Users/senny/Projects/queue_classic/lib/queue_classic.rb:64:in `new' /Users/senny/Projects/queue_classic/lib/queue_classic.rb:64:in `default_conn_adapter' test/worker_test.rb:223:in `with_database' test/worker_test.rb:193:in `test_init_worker_with_arg' ```
If it is displayed only at the place of the closest source code, debugging is becomes more comfortable.