Class: HydroponicBean::Connection

Inherits:
Object
  • Object
show all
Includes:
Protocol
Defined in:
lib/hydroponic_bean/connection.rb

Constant Summary

Constants included from Protocol

Protocol::BAD_FORMAT, Protocol::DRAINING, Protocol::EXPECTED_CRLF, Protocol::INTERNAL_ERROR, Protocol::JOB_TOO_BIG, Protocol::NOT_FOUND, Protocol::OUT_OF_MEMORY, Protocol::UNKNOWN_COMMAND

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Protocol

#parse

Methods included from Commands

#for_job

Methods included from HydroponicBean::Commands::Other

#kick_job, #peek, #peek_buried, #peek_delayed, #peek_ready, #stats_job

Methods included from HydroponicBean::Commands::Tube

#kick, #list_tubes, #list_tubes_watched, #pause_tube, #stats_tube

Methods included from HydroponicBean::Commands::Worker

#bury, #delete, #ignore, #release, #reserve, #reserve_with_timeout, #touch, #watch

Methods included from HydroponicBean::Commands::Producer

#put, #use

Methods included from Data

#create_job, #current_tube, #current_tube_name, #deadline_soon?, #reservable_jobs, #reserve_job, #stats, #wait_for_job, #watched_tube_names, #watched_tubes

Constructor Details

#initializeConnection

Returns a new instance of Connection.



10
11
12
13
14
15
# File 'lib/hydroponic_bean/connection.rb', line 10

def initialize
  @_read, @_write = IO.pipe
  @worker, @producer = false
  @waiting = false
  HydroponicBean.add_connection(self)
end

Instance Attribute Details

#waitingObject Also known as: waiting?

Returns the value of attribute waiting.



7
8
9
# File 'lib/hydroponic_bean/connection.rb', line 7

def waiting
  @waiting
end

Instance Method Details

#closeObject



39
40
41
42
43
# File 'lib/hydroponic_bean/connection.rb', line 39

def close
  @_read.close
  @_write.close
  HydroponicBean.remove_connection(self)
end

#closed?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/hydroponic_bean/connection.rb', line 22

def closed?
  @_write.closed?
end

#producer!Object



20
# File 'lib/hydroponic_bean/connection.rb', line 20

def producer!; @producer = true; end

#producer?Boolean

Returns:

  • (Boolean)


19
# File 'lib/hydroponic_bean/connection.rb', line 19

def producer?; @producer;        end

#read(bytes) ⇒ Object



31
32
33
# File 'lib/hydroponic_bean/connection.rb', line 31

def read(bytes)
  @_read.read(bytes)
end

#readlineObject



35
36
37
# File 'lib/hydroponic_bean/connection.rb', line 35

def readline
  @_read.readline
end

#worker!Object



18
# File 'lib/hydroponic_bean/connection.rb', line 18

def worker!;   @worker = true;   end

#worker?Boolean

Returns:

  • (Boolean)


17
# File 'lib/hydroponic_bean/connection.rb', line 17

def worker?;   @worker;          end

#write(command) ⇒ Object

Necessary interface used by beaneater



27
28
29
# File 'lib/hydroponic_bean/connection.rb', line 27

def write(command)
  parse(StringIO.new(command))
end