Class: MysqlImport
- Inherits:
-
Object
show all
- Includes:
- Logging
- Defined in:
- lib/mysql_import.rb,
lib/mysql_import/logger.rb,
lib/mysql_import/version.rb
Defined Under Namespace
Modules: Logging
Classes: Break, Logger, Result
Constant Summary
collapse
- VERSION =
'0.5.1'
Instance Method Summary
collapse
Constructor Details
#initialize(config, opts = {}) ⇒ MysqlImport
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/mysql_import.rb', line 8
def initialize(config, opts = {})
@stash = []
@lock = opts.fetch(:lock, false)
@concurrency = opts.has_key?(:concurrency) ? opts[:concurrency].to_i : 2
pool = @concurrency.zero? ? 1 : @concurrency
sql_opts = opts.fetch(:sql_opts, {})
@client = ConnectionPool.new(size: pool) { LoadDataInfile2::Client.new(config, sql_opts) }
@result = Result.new
end
|
Instance Method Details
#add(file_path, opts = {}) ⇒ Object
19
20
21
|
# File 'lib/mysql_import.rb', line 19
def add(file_path, opts = {})
@stash.push([file_path, opts])
end
|
#import(filters = nil) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/mysql_import.rb', line 23
def import(filters = nil)
Parallel.each(filtered_list(filters), parallel_opts) do |args|
@client.with do |cli|
run_import(cli, *args)
end
end
end
|