Class: SquashRepeater::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/squash_repeater/configure.rb

Defined Under Namespace

Classes: Squash

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/squash_repeater/configure.rb', line 18

def initialize
  #NB: You definitely want to think about changing this to something more "substantial"; beanstalkd goes down, you'll lose data.
  self.logger = Logger.new(STDERR)
  self.capture_timeout = 2  # seconds

  backburner do |c|
    # The nature of SquashRepeater is that a tiny local queueing system
    # captures the Squash notification, and retransmits it from a worker.
    # Therefore, we assume beanstalkd is running locally:
    c.beanstalk_url = "beanstalk://localhost"
    #c.beanstalk_url = "beanstalk://127.0.0.1"
    c.tube_namespace   = "squash-repeater"

    c.max_job_retries = 10 # retry jobs 10 times
    c.retry_delay = 30 # wait 30 seconds in between retries

    # NB: This relies on forking behaviour!
    # NB: Both ::Simple and ::Forking seem to have a bug in them (https://github.com/nesquena/backburner/issues/93)
    c.default_worker = Backburner::Workers::ThreadsOnFork

    #c.on_error = lambda { |ex| Airbrake.notify(ex) }  #FUTURE: Choose a better failure mode:
  end
end

Instance Attribute Details

#capture_timeoutObject

Returns the value of attribute capture_timeout.



16
17
18
# File 'lib/squash_repeater/configure.rb', line 16

def capture_timeout
  @capture_timeout
end

#loggerObject

Returns the value of attribute logger.



15
16
17
# File 'lib/squash_repeater/configure.rb', line 15

def logger
  @logger
end

Instance Method Details

#backburner(&p) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/squash_repeater/configure.rb', line 42

def backburner(&p)
  if block_given?
    Backburner.configure(&p)
  else
    Backburner.configuration
  end
end

#loggersObject

Return an array of all available loggers



59
60
61
# File 'lib/squash_repeater/configure.rb', line 59

def loggers
  [logger, backburner.logger]  #FUTURE: Can we somehow get a Squash logger for this?
end

#squash(&p) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/squash_repeater/configure.rb', line 50

def squash(&p)
  if block_given?
    SquashRepeater::Configuration::Squash.configure(&p)
  else
    SquashRepeater::Configuration::Squash.configuration
  end
end