class SpiderGazelle::Gazelle

Attributes

thread[R]

Public Class Methods

new(thread, type) click to toggle source
# File lib/spider-gazelle/gazelle.rb, line 12
def initialize(thread, type)
    raise ArgumentError, "type must be one of #{MODES}" unless MODES.include?(type)
    
    @type = type
    @logger = Logger.instance
    @thread = thread
    @thread.ref
end

Public Instance Methods

run!(options) click to toggle source
# File lib/spider-gazelle/gazelle.rb, line 25
def run!(options)
    @options = options
    @logger.verbose { "Gazelle: #{@type} started" }

    self
end
shutdown(defer) click to toggle source
# File lib/spider-gazelle/gazelle.rb, line 32
def shutdown(defer)
    @thread.schedule do
        # TODO:: Wait for the requests to finish
        @thread.unref
        @logger.verbose { "Gazelle: #{@type} shutting down" }
        @thread.stop
        defer.resolve(true)
    end
end