Sha256: 38dd02c5dda0f5474f8703fb501ec2feea96789a82b5a8de5f7dbe8a7e6e668a

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

# encoding: utf-8

require 'heroku'

module HireFire
  module Environment
    class Heroku < Base

      private

      ##
      # Either retrieves the amount of currently running workers,
      # or set the amount of workers to a specific amount by providing a value
      #
      # @overload workers(amount = nil)
      #   @param [Fixnum] amount will tell heroku to run N workers
      #   @return [nil]
      # @overload workers(amount = nil)
      #   @param [nil] amount
      #   @return [Fixnum] will request the amount of currently running workers from Heroku
      def workers(amount = nil)

        #
        # Returns the amount of Delayed Job
        # workers that are currently running on Heroku
        if amount.nil?
          return client.info(ENV['APP_NAME'])[:workers].to_i
        end

        ##
        # Sets the amount of Delayed Job
        # workers that need to be running on Heroku
        client.set_workers(ENV['APP_NAME'], amount)
      end

      ##
      # @return [Heroku::Client] instance of the heroku client
      def client
        @client ||= ::Heroku::Client.new(
          ENV['HIREFIRE_EMAIL'], ENV['HIREFIRE_PASSWORD']
        )
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
samoli-hirefire-0.1.1 lib/hirefire/environment/heroku.rb
hirefire-0.1.1 lib/hirefire/environment/heroku.rb
hirefire-0.1.0 lib/hirefire/environment/heroku.rb