Class: QProcessor::BeanstalkSource

Inherits:
Object
  • Object
show all
Defined in:
lib/qprocessor/beanstalk_source.rb

Constant Summary collapse

BEANSTALK_URL_PATTERN =

A constant for a regular expression to match Beanstalk URLs

/^beanstalk:\/\/([^:\/]+)[:]?([\d]*)[\/]?(.*)$/
DEFAULT_TUBE_NAME =

The default Beanstalk tube name.

"default"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBeanstalkSource

Returns a new instance of BeanstalkSource.



12
13
14
# File 'lib/qprocessor/beanstalk_source.rb', line 12

def initialize
  @name = "Beanstalk Source"
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/qprocessor/beanstalk_source.rb', line 15

def name
  @name
end

Instance Method Details

#get {|message| ... } ⇒ Object

This method blocks until a job is available, at which points it is returned.

Yields:

  • (message)


19
20
21
22
23
24
# File 'lib/qprocessor/beanstalk_source.rb', line 19

def get
  job     = connection.reserve
  message = QProcessor::BeanstalkMessage.new(job)
  yield message if block_given?
  message
end