Update the way scalers are loaded #11

Closed
wants to merge 16 commits into
from

Conversation

Projects
None yet
1 participant
Contributor

bdotdub commented Aug 8, 2011

Add functionality to add user defined scalers.

From the main commit (bdotdub/workless@20c19eb):

Change the way scalers are loaded

* Previously, the scaler needed to be defined and loaded from
  within the workless gem. Therefore, if you wanted to implement
  a new scaler, you'd have to fork and implement. Now, you can
  defined a scaler by putting it in the Delayed::Workless::Scaler
  module and you should be good to go
* How this works technically:
  - The previous way was to require the scaler from within the gem
    directory, and then instantiate a new instance of the scaler
  - Now, the scalers only have class methods as "callbacks". Since
    the scalers aren't holding content (ie. instance variables),
    there's no need for the scalers to be instantiated
* For scalers that need to talk to heroku, you need to extend the
  scaler to use Delayed::Workless::Scaler::HerokuClient
* Example scaler:

    class Delayed::Workless::Scaler::SuperDuperRandom

      extend Delayed::Workless::Scaler::HerokuClient

      def self.up
        client.set_workers(ENV['APP_NAME'], rand(24)
      end

      def self.down
        client.set_workers(0)
      end

    end

bdotdub added some commits Apr 8, 2011

Change the way scalers are loaded
* Previously, the scaler needed to be defined and loaded from
  within the workless gem. Therefore, if you wanted to implement
  a new scaler, you'd have to fork and implement. Now, you can
  defined a scaler by putting it in the Delayed::Workless::Scaler
  module and you should be good to go
* How this works technically:
  - The previous way was to require the scaler from within the gem
    directory, and then instantiate a new instance of the scaler
  - Now, the scalers only have class methods as "callbacks". Since
    the scalers aren't holding content (ie. instance variables),
    there's no need for the scalers to be instantiated
* For scalers that need to talk to heroku, you need to extend the
  scaler to use Delayed::Workless::Scaler::HerokuClient
* Example scaler:

    class Delayed::Workless::Scaler::SuperDuperRandom

      extend Delayed::Workless::Scaler::HerokuClient

      def self.up
        client.set_workers(ENV['APP_NAME'], rand(24)
      end

      def self.down
        client.set_workers(0)
      end

    end
Contributor

bdotdub commented Oct 21, 2011

Reopening a pull request. This one is too messy. Will squash a bunch of commits

@bdotdub bdotdub closed this Oct 21, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment