Class: Hoth::Transport::Beanstalkd

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

Instance Attribute Summary collapse

Attributes inherited from Base

#encoder

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Beanstalkd

Returns a new instance of Beanstalkd.



14
15
16
17
# File 'lib/hoth/transport/beanstalkd.rb', line 14

def initialize(*args)
  super
  @connection = Beanstalk::Connection.new("#{endpoint.host}:#{endpoint.port}")
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



12
13
14
# File 'lib/hoth/transport/beanstalkd.rb', line 12

def connection
  @connection
end

Instance Method Details

#call_remote_with(*args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hoth/transport/beanstalkd.rb', line 19

def call_remote_with(*args)
  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}"
  end
end

#tube_nameObject



31
32
33
# File 'lib/hoth/transport/beanstalkd.rb', line 31

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