Class: Hoth::Transport::Beanstalkd

Inherits:
Base
  • Object
show all
Defined in:
lib/hoth/transport/beanstalkd.rb

Instance Attribute Summary

Attributes inherited from Base

#encoder

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Hoth::Transport::Base

Instance Method Details

#call_remote_with(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hoth/transport/beanstalkd.rb', line 12

def call_remote_with(*args)
  connection = Beanstalk::Connection.new("#{endpoint.host}:#{endpoint.port}")
  connection.use(tube_name)

  begin
    encoded_args = encoder.encode(args)
    Hoth::Logger.debug "encoded_args: #{encoded_args}"
    connection.put encoded_args
  rescue => e
    Hoth::Logger.warn "An error occured while sending a payload to beanstalkd: #{e.message}"
  ensure
    connection.close
  end
end

#tube_nameObject



27
28
29
# File 'lib/hoth/transport/beanstalkd.rb', line 27

def tube_name
  @tube_name ||= "#{self.module.name}/#{name}".dasherize
end