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.



152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/groonga-query-log/replayer.rb', line 152

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
  @requests_path = nil
  @responses_path = nil
  @target_command_names = []
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.



148
149
150
# File 'lib/groonga-query-log/replayer.rb', line 148

def disable_cache=(value)
  @disable_cache = value
end

#hostObject

Returns the value of attribute host.



142
143
144
# File 'lib/groonga-query-log/replayer.rb', line 142

def host
  @host
end

#n_clientsObject

Returns the value of attribute n_clients.



146
147
148
# File 'lib/groonga-query-log/replayer.rb', line 146

def n_clients
  @n_clients
end

#portObject

Returns the value of attribute port.



143
144
145
# File 'lib/groonga-query-log/replayer.rb', line 143

def port
  @port
end

#protocolObject

Returns the value of attribute protocol.



144
145
146
# File 'lib/groonga-query-log/replayer.rb', line 144

def protocol
  @protocol
end

#read_timeoutObject

Returns the value of attribute read_timeout.



145
146
147
# File 'lib/groonga-query-log/replayer.rb', line 145

def read_timeout
  @read_timeout
end

#request_queue_sizeObject



189
190
191
# File 'lib/groonga-query-log/replayer.rb', line 189

def request_queue_size
  @request_queue_size || @n_clients * 3
end

#requests_pathObject

Returns the value of attribute requests_path.



150
151
152
# File 'lib/groonga-query-log/replayer.rb', line 150

def requests_path
  @requests_path
end

#responses_pathObject

Returns the value of attribute responses_path.



151
152
153
# File 'lib/groonga-query-log/replayer.rb', line 151

def responses_path
  @responses_path
end

#target_command_namesObject

Returns the value of attribute target_command_names.



149
150
151
# File 'lib/groonga-query-log/replayer.rb', line 149

def target_command_names
  @target_command_names
end

Instance Method Details

#create_client(&block) ⇒ Object



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

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

#create_request_output(&block) ⇒ Object



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

def create_request_output(&block)
  if @requests_path
    File.open(@requests_path, "w", &block)
  else
    NullOutput.open(&block)
  end
end

#create_responses_output(&block) ⇒ Object



181
182
183
184
185
186
187
# File 'lib/groonga-query-log/replayer.rb', line 181

def create_responses_output(&block)
  if @responses_path
    File.open(@responses_path, "w", &block)
  else
    NullOutput.open(&block)
  end
end

#disable_cache?Boolean

Returns:

  • (Boolean)


193
194
195
# File 'lib/groonga-query-log/replayer.rb', line 193

def disable_cache?
  @disable_cache
end

#target_command_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


197
198
199
200
201
202
203
204
# File 'lib/groonga-query-log/replayer.rb', line 197

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