Class: ITRP::Cmd_keyspace
Instance Attribute Summary
Attributes inherited from Cmd
#attach_cmd, #children, #enabled_in_state, #trigger
Instance Method Summary collapse
- #enter(cmdline) ⇒ Object
-
#initialize(e) ⇒ Cmd_keyspace
constructor
A new instance of Cmd_keyspace.
Methods inherited from Cmd
#appstate, #completions, #find_node, #is_root?, #place_node, #print_state, #set_time_window, #treeprint
Constructor Details
#initialize(e) ⇒ Cmd_keyspace
Returns a new instance of Cmd_keyspace.
4 5 6 7 8 9 |
# File 'lib/handlers/keyspace.rb', line 4 def initialize (e) super(e) @enabled_in_state = :counter @attach_cmd = '' @trigger = 'keyspace' end |
Instance Method Details
#enter(cmdline) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/handlers/keyspace.rb', line 13 def enter(cmdline) patt = cmdline.scan(/keyspace\s+(\S+)\s*(\S+)/).flatten p "#{patt[0]} to #{patt[1]}" use_spaces = [ TRP::KeySpaceRequest::KeySpace.new( :from_key => TRP::KeyT.new( :label => patt[0]), :to_key => TRP::KeyT.new( :label => patt[1]) ) ] req =TrisulRP::Protocol.mk_request(TRP::Message::Command::KEYSPACE_REQUEST, :counter_group => @appenv.context_data[:cgguid], :time_interval => appstate( :time_interval), :totals_only => true ) rows = [] TrisulRP::Protocol.get_response_zmq(@appenv.zmq_endpt,req) do |resp| resp.hits.each_with_index do |kt,i | rows << [ i, kt.key, kt.label, kt.readable ] end p "TOTAL HITS = #{resp.total_hits}" end table = Terminal::Table.new( :headings => %w(# Key Label Readable ), :rows => rows) puts(table) end |