Class: GroongaQueryLog::Replayer::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga-query-log/replayer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/groonga-query-log/replayer.rb', line 180

def initialize
  @host = "127.0.0.1"
  @port = 10041
  @protocol = :http
  @read_timeout = Groonga::Client::Default::READ_TIMEOUT
  @n_clients = 8
  @request_queue_size = nil
  @disable_cache = false
  @target_command_names = []
  @requests_path = nil
  @responses_path = nil
  @error_responses_path = nil
  @output_type = nil
end

Instance Attribute Details

#disable_cache=(value) ⇒ Object (writeonly)

Sets the attribute disable_cache

Parameters:

  • value

    the value to set the attribute disable_cache to.



174
175
176
# File 'lib/groonga-query-log/replayer.rb', line 174

def disable_cache=(value)
  @disable_cache = value
end

#error_responses_pathObject

Returns the value of attribute error_responses_path.



178
179
180
# File 'lib/groonga-query-log/replayer.rb', line 178

def error_responses_path
  @error_responses_path
end

#hostObject

Returns the value of attribute host.



168
169
170
# File 'lib/groonga-query-log/replayer.rb', line 168

def host
  @host
end

#n_clientsObject

Returns the value of attribute n_clients.



172
173
174
# File 'lib/groonga-query-log/replayer.rb', line 172

def n_clients
  @n_clients
end

#output_typeObject

Returns the value of attribute output_type.



179
180
181
# File 'lib/groonga-query-log/replayer.rb', line 179

def output_type
  @output_type
end

#portObject

Returns the value of attribute port.



169
170
171
# File 'lib/groonga-query-log/replayer.rb', line 169

def port
  @port
end

#protocolObject

Returns the value of attribute protocol.



170
171
172
# File 'lib/groonga-query-log/replayer.rb', line 170

def protocol
  @protocol
end

#read_timeoutObject

Returns the value of attribute read_timeout.



171
172
173
# File 'lib/groonga-query-log/replayer.rb', line 171

def read_timeout
  @read_timeout
end

#request_queue_sizeObject



215
216
217
# File 'lib/groonga-query-log/replayer.rb', line 215

def request_queue_size
  @request_queue_size || @n_clients * 3
end

#requests_pathObject

Returns the value of attribute requests_path.



176
177
178
# File 'lib/groonga-query-log/replayer.rb', line 176

def requests_path
  @requests_path
end

#responses_pathObject

Returns the value of attribute responses_path.



177
178
179
# File 'lib/groonga-query-log/replayer.rb', line 177

def responses_path
  @responses_path
end

#target_command_namesObject

Returns the value of attribute target_command_names.



175
176
177
# File 'lib/groonga-query-log/replayer.rb', line 175

def target_command_names
  @target_command_names
end

Instance Method Details

#create_client(&block) ⇒ Object



195
196
197
198
199
200
201
# File 'lib/groonga-query-log/replayer.rb', line 195

def create_client(&block)
  Groonga::Client.open(:host     => @host,
                       :port     => @port,
                       :protocol => @protocol,
                       :read_timeout => @read_timeout,
                       &block)
end

#create_error_responses_output(&block) ⇒ Object



211
212
213
# File 'lib/groonga-query-log/replayer.rb', line 211

def create_error_responses_output(&block)
  create_output(@error_responses_path, &block)
end

#create_request_output(&block) ⇒ Object



203
204
205
# File 'lib/groonga-query-log/replayer.rb', line 203

def create_request_output(&block)
  create_output(@requests_path, &block)
end

#create_responses_output(&block) ⇒ Object



207
208
209
# File 'lib/groonga-query-log/replayer.rb', line 207

def create_responses_output(&block)
  create_output(@responses_path, &block)
end

#disable_cache?Boolean

Returns:

  • (Boolean)


219
220
221
# File 'lib/groonga-query-log/replayer.rb', line 219

def disable_cache?
  @disable_cache
end

#target_command_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


223
224
225
226
227
228
229
230
# File 'lib/groonga-query-log/replayer.rb', line 223

def target_command_name?(name)
  return true if @target_command_names.empty?
  @target_command_names.any? do |name_pattern|
    flags = 0
    flags |= File::FNM_EXTGLOB if File.const_defined?(:FNM_EXTGLOB)
    File.fnmatch(name_pattern, name, flags)
  end
end