class GroongaQueryLog::Command::Replay
Public Class Methods
new()
click to toggle source
# File lib/groonga-query-log/command/replay.rb, line 25 def initialize @options = Replayer::Options.new end
Public Instance Methods
run(command_line)
click to toggle source
# File lib/groonga-query-log/command/replay.rb, line 29 def run(command_line) input_paths = create_parser.parse(command_line) replayer = Replayer.new(@options) if input_paths.empty? replayer.replay($stdin) else input_paths.each do |input_path| File.open(input_path) do |input| replayer.replay(input) end end end true end
Private Instance Methods
create_parser()
click to toggle source
# File lib/groonga-query-log/command/replay.rb, line 45 def create_parser parser = OptionParser.new parser.version = VERSION parser.banner += " QUERY_LOG" parser.separator("") parser.separator("Options:") parser.on("--host=HOST", "Host name or IP address of Groonga server", "[#{@options.host}]") do |host| @options.host = host end parser.on("--port=PORT", Integer, "Port number of Groonga server", "[#{@options.port}]") do |port| @options.port = port end available_protocols = [:gqtp, :http] available_protocols_label = "(#{available_protocols.join(', ')})" parser.on("--protocol=PROTOCOL", available_protocols, "Protocol of Groonga server", "[#{@options.protocol}]", available_protocols_label) do |protocol| @options.protocol = protocol end parser.on("--read-timeout=TIMEOUT", Integer, "Read timeout", "[#{@options.read_timeout}]") do |read_timeout| @options.read_timeout = read_timeout end parser.on("--n-clients=N", Integer, "The max number of concurrency", "[#{@options.n_clients}]") do |n_clients| @options.n_clients = n_clients end parser.on("--request-queue-size=SIZE", Integer, "The size of request queue", "[auto]") do |size| @options.request_queue_size = size end parser.on("--disable-cache", "Add 'cache=no' parameter to request", "[#{@options.disable_cache?}]") do @options.disable_cache = true end parser.on("--target-command-name=NAME", "Add NAME to target command names", "You can specify this option zero or more times", "See also --target-command-names") do |name| @options.target_command_names << name end target_command_names_label = @options.target_command_names.join(", ") parser.on("--target-command-names=NAME1,NAME2,...", Array, "Replay only NAME1,NAME2,... commands", "You can use glob to choose command name", "[#{target_command_names_label}]") do |names| @options.target_command_names = names end parser.on("--output-requests=PATH", "Output requests to PATH", "[not output]") do |path| @options.requests_path = path end parser.on("--output-responses=PATH", "Output responses to PATH", "[not output]") do |path| @options.responses_path = path end parser.on("--output-error-responses=PATH", "Output only error responses to PATH", "[not output]") do |path| @options.error_responses_path = path end available_output_types = ["json", "msgpack", "apache-arrow"] available_output_type_labels = available_output_types.join(", ") parser.on("--output-type=TYPE", available_output_types, "Use TYPE as the output type", "(#{available_output_type_labels})", "[use the original output type]") do |type| @options.output_type = type end end