class StalkClimber::Tube
Constants
- STATS_ATTRIBUTES
List of available attributes available via the stats object.
- STATS_METHODS
Lookup table of which method to call to retrieve each stat
Public Instance Methods
Returns the number of times the delete command has been called for jobs in the tube.
# File lib/stalk_climber/tube.rb, line 103
Returns the number of times the pause-tube command has been called on the tube.
# File lib/stalk_climber/tube.rb, line 110
Returns the number of jobs in the tube that are currently buried.
# File lib/stalk_climber/tube.rb, line 117
Returns the number of jobs in the tube that are currently buried.
# File lib/stalk_climber/tube.rb, line 123
Returns the number of jobs in the tube that are currently ready.
# File lib/stalk_climber/tube.rb, line 129
Returns the number of jobs in the tube that are currently reserved.
# File lib/stalk_climber/tube.rb, line 135
Returns the number of jobs currently in the tube with a priority less than 1024, and thus deemed urgent.
# File lib/stalk_climber/tube.rb, line 141
Returns the number of connections that are currently using the tube.
# File lib/stalk_climber/tube.rb, line 148
Returns the number of connections that have issued reserve requests for the tube and are currently awaiting a reply.
# File lib/stalk_climber/tube.rb, line 154
Returns the number of connections that are watching the tube.
# File lib/stalk_climber/tube.rb, line 161
Determines if a tube exists by retrieving stats for the tube. If Beaneater can't find the tube then it oes not exist and false is returned. If stats are retrieved successfully then true is returned. The stats command is used because it will return a response of near constant size, whereas, depending on the environment, list-tubes could return a much larger response. Additionally, updated stats information is usually more valuable than a list of tubes that is immediately discarded.
# File lib/stalk_climber/tube.rb, line 37 def exists? return !stats.nil? rescue Beaneater::NotFoundError return false end
Returns pause stat which indicates the duration the tube is currently paused for. The name pause_time
is used because Beaneater::Tube already defines a pause method.
# File lib/stalk_climber/tube.rb, line 50 def pause_time(force_refresh = false) return stats(force_refresh).pause end
Returns the number of seconds remaining before the tube is no longer paused.
# File lib/stalk_climber/tube.rb, line 167
Returns related stats for this tube.
@tube.stats.current_jobs_delayed #=> 3
# File lib/stalk_climber/tube.rb, line 62 def stats(force_refresh = true) if force_refresh || @stats.nil? stats = transmit_to_all("stats-tube #{name}", :merge => true)[:body] @stats = Beaneater::StatStruct.from_hash(stats) end return @stats end
Returns a hash of all tube attributes derived from updated stats
tube = StalkClimber::Tube.new(connection_pool, 'stalk_climber') tube.to_h #=> {"cmd-delete"=>100, "cmd-pause-tube"=>101, "current-jobs-buried"=>102, "current-jobs-delayed"=>103, "current-jobs-ready"=>104, "current-jobs-reserved"=>105, "current-jobs-urgent"=>106, "current-using"=>107, "current-waiting"=>108, "current-watching"=>109, "name"=>"stalk_climber", "pause"=>111, "pause-time-left"=>110, "total-jobs"=>112}
# File lib/stalk_climber/tube.rb, line 79 def to_h stats return Hash[ STATS_METHODS.map do |stat, method_name| [stat, stats(false).send(method_name)] end ] end
Returns string representation of the tube
tube = StalkClimber::Tube.new(connection_pool, 'stalk_climber') tube.to_s #=> #<StalkClimber::Tube name="stalk_climber">
# File lib/stalk_climber/tube.rb, line 97 def to_s "#<StalkClimber::Tube name=#{name}>" end
Returns the total number of jobs that have been registered with the tube since the tube was most recently created.
# File lib/stalk_climber/tube.rb, line 174