bricolage 5.22.3 → 5.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bricolage/jobclass.rb +18 -4
- data/lib/bricolage/version.rb +1 -1
- data/test/home/Gemfile.lock +9 -40
- metadata +1 -18
- data/jobclass/td-delete.rb +0 -20
- data/jobclass/td-export.rb +0 -30
- data/lib/bricolage/tddatasource.rb +0 -116
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 68aff8b010487891f214258a2c0b3e4c175e9195
|
|
4
|
+
data.tar.gz: c9cf9a4ee6d938e7b05456a0643a687094cc379a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c923cd19ed97f203a12e090efafd55edfbe79f2807cd739e92704d1788caa45bebe074c56ce156276ee0af69fbf9cbfcbb7b0a25bdcb73068c93d9df8b5aed3
|
|
7
|
+
data.tar.gz: 25d863da9ce8fb1f0d380f4fe9ce80cbe8f9201fc82ca1ad3fe49259453f6a12325723254884ac87b77b0a22da5c8856c0cb10332539e7832fa5ebffc1b01c92
|
data/lib/bricolage/jobclass.rb
CHANGED
|
@@ -17,13 +17,27 @@ module Bricolage
|
|
|
17
17
|
CLASSES[id] = c
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
LOAD_PATHES = []
|
|
21
|
+
|
|
22
|
+
def JobClass.add_load_path(path)
|
|
23
|
+
LOAD_PATHES.push path
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def JobClass.primary_load_path
|
|
27
|
+
load_path_for_lib_file(__FILE__)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def JobClass.load_path_for_lib_file(path)
|
|
31
|
+
srcdir = Pathname(path).realpath.parent.parent.parent.cleanpath
|
|
32
|
+
srcdir + 'jobclass'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
add_load_path primary_load_path
|
|
22
36
|
|
|
23
37
|
def JobClass.get(id)
|
|
24
38
|
unless CLASSES[id.to_s]
|
|
25
39
|
begin
|
|
26
|
-
path =
|
|
40
|
+
path = LOAD_PATHES.map {|prefix| prefix + "#{id}.rb" }.detect(&:exist?)
|
|
27
41
|
raise ParameterError, "no such job class: #{id}" unless path
|
|
28
42
|
::Bricolage.module_eval File.read(path), path.to_path, 1
|
|
29
43
|
rescue SystemCallError => err
|
|
@@ -35,7 +49,7 @@ module Bricolage
|
|
|
35
49
|
end
|
|
36
50
|
|
|
37
51
|
def JobClass.list
|
|
38
|
-
|
|
52
|
+
LOAD_PATHES.map {|dir|
|
|
39
53
|
Dir.glob("#{dir}/*.rb").map {|path| File.basename(path, '.rb') }
|
|
40
54
|
}.flatten.uniq.sort
|
|
41
55
|
end
|
data/lib/bricolage/version.rb
CHANGED
data/test/home/Gemfile.lock
CHANGED
|
@@ -1,65 +1,34 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ../..
|
|
3
3
|
specs:
|
|
4
|
-
bricolage (5.
|
|
4
|
+
bricolage (5.23.0)
|
|
5
5
|
aws-sdk (~> 2)
|
|
6
6
|
mysql2
|
|
7
7
|
pg (~> 0.18.0)
|
|
8
8
|
redis (>= 3.0.0)
|
|
9
|
-
td
|
|
10
9
|
|
|
11
10
|
GEM
|
|
12
11
|
remote: https://rubygems.org/
|
|
13
12
|
specs:
|
|
14
|
-
aws-sdk (2.
|
|
15
|
-
aws-sdk-resources (= 2.
|
|
16
|
-
aws-sdk-core (2.
|
|
13
|
+
aws-sdk (2.7.5)
|
|
14
|
+
aws-sdk-resources (= 2.7.5)
|
|
15
|
+
aws-sdk-core (2.7.5)
|
|
17
16
|
aws-sigv4 (~> 1.0)
|
|
18
17
|
jmespath (~> 1.0)
|
|
19
|
-
aws-sdk-resources (2.
|
|
20
|
-
aws-sdk-core (= 2.
|
|
18
|
+
aws-sdk-resources (2.7.5)
|
|
19
|
+
aws-sdk-core (= 2.7.5)
|
|
21
20
|
aws-sigv4 (1.0.0)
|
|
22
|
-
coderay (1.1.
|
|
23
|
-
fluent-logger (0.6.1)
|
|
24
|
-
msgpack (>= 0.5.6, < 2)
|
|
25
|
-
hirb (0.7.3)
|
|
26
|
-
httpclient (2.8.3)
|
|
21
|
+
coderay (1.1.1)
|
|
27
22
|
jmespath (1.3.1)
|
|
28
|
-
json (2.0.2)
|
|
29
23
|
method_source (0.8.2)
|
|
30
|
-
msgpack (1.0.2)
|
|
31
24
|
mysql2 (0.4.5)
|
|
32
|
-
parallel (1.8.0)
|
|
33
25
|
pg (0.18.4)
|
|
34
|
-
pry (0.10.
|
|
26
|
+
pry (0.10.4)
|
|
35
27
|
coderay (~> 1.1.0)
|
|
36
28
|
method_source (~> 0.8.1)
|
|
37
29
|
slop (~> 3.4)
|
|
38
|
-
redis (3.3.
|
|
39
|
-
ruby-progressbar (1.8.1)
|
|
40
|
-
rubyzip (1.1.7)
|
|
30
|
+
redis (3.3.3)
|
|
41
31
|
slop (3.6.0)
|
|
42
|
-
td (0.15.2)
|
|
43
|
-
hirb (>= 0.4.5)
|
|
44
|
-
msgpack
|
|
45
|
-
parallel (~> 1.8.0)
|
|
46
|
-
ruby-progressbar (~> 1.7)
|
|
47
|
-
rubyzip (~> 1.1.7)
|
|
48
|
-
td-client (~> 0.8.85)
|
|
49
|
-
td-logger (>= 0.3.21, < 2)
|
|
50
|
-
yajl-ruby (~> 1.1)
|
|
51
|
-
zip-zip (~> 0.3)
|
|
52
|
-
td-client (0.8.85)
|
|
53
|
-
httpclient (>= 2.7)
|
|
54
|
-
json (>= 1.7.6)
|
|
55
|
-
msgpack (>= 0.5.6, < 2)
|
|
56
|
-
td-logger (0.3.26)
|
|
57
|
-
fluent-logger (>= 0.5.0, < 2.0)
|
|
58
|
-
msgpack (>= 0.5.6, < 2.0)
|
|
59
|
-
td-client (~> 0.8.66)
|
|
60
|
-
yajl-ruby (1.3.0)
|
|
61
|
-
zip-zip (0.3)
|
|
62
|
-
rubyzip (>= 1.0.0)
|
|
63
32
|
|
|
64
33
|
PLATFORMS
|
|
65
34
|
ruby
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bricolage
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.23.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Minero Aoki
|
|
@@ -52,20 +52,6 @@ dependencies:
|
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: td
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - ">="
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
62
|
-
type: :runtime
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - ">="
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
69
55
|
- !ruby/object:Gem::Dependency
|
|
70
56
|
name: redis
|
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -164,8 +150,6 @@ files:
|
|
|
164
150
|
- jobclass/s3-put.rb
|
|
165
151
|
- jobclass/sql.rb
|
|
166
152
|
- jobclass/streaming_load.rb
|
|
167
|
-
- jobclass/td-delete.rb
|
|
168
|
-
- jobclass/td-export.rb
|
|
169
153
|
- jobclass/unload.rb
|
|
170
154
|
- jobclass/wait-file.rb
|
|
171
155
|
- lib/bricolage.rb
|
|
@@ -202,7 +186,6 @@ files:
|
|
|
202
186
|
- lib/bricolage/sqlstatement.rb
|
|
203
187
|
- lib/bricolage/sqlutils.rb
|
|
204
188
|
- lib/bricolage/taskqueue.rb
|
|
205
|
-
- lib/bricolage/tddatasource.rb
|
|
206
189
|
- lib/bricolage/vacuumlock.rb
|
|
207
190
|
- lib/bricolage/variables.rb
|
|
208
191
|
- lib/bricolage/version.rb
|
data/jobclass/td-delete.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
JobClass.define('td-delete') {
|
|
2
|
-
parameters {|params|
|
|
3
|
-
params.add DestTableParam.new(optional: false)
|
|
4
|
-
params.add DataSourceParam.new('td')
|
|
5
|
-
params.add DateParam.new('from', 'DATE', 'Start date of logs to delete (%Y-%m-%d).')
|
|
6
|
-
params.add DateParam.new('to', 'DATE', 'End date of logs to delete (%Y-%m-%d).')
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declarations {|params|
|
|
10
|
-
Declarations.new("dest_table" => nil)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
script {|params, script|
|
|
14
|
-
script.task(params['data-source']) {|task|
|
|
15
|
-
task.delete params['dest-table'],
|
|
16
|
-
from: params['from'],
|
|
17
|
-
to: params['to']
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
data/jobclass/td-export.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
JobClass.define('td-export') {
|
|
2
|
-
parameters {|params|
|
|
3
|
-
params.add SQLFileParam.new
|
|
4
|
-
params.add DestFileParam.new
|
|
5
|
-
params.add SrcTableParam.new
|
|
6
|
-
params.add StringParam.new('src-database', 'NAME', 'Source TD database name.', optional: true)
|
|
7
|
-
params.add EnumParam.new('format', %w(msgpack tsv csv json), 'Target file format.', default: 'msgpack')
|
|
8
|
-
params.add OptionalBoolParam.new('gzip', 'If true, compresses target file by gzip.')
|
|
9
|
-
params.add OptionalBoolParam.new('override', 'If true, clears target file. Otherwise causes error.')
|
|
10
|
-
params.add DataSourceParam.new('td')
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
parameters_filter {|job|
|
|
14
|
-
job.provide_sql_file_by_job_id
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
declarations {|params|
|
|
18
|
-
params['sql-file'].declarations
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
script {|params, script|
|
|
22
|
-
script.task(params['data-source']) {|task|
|
|
23
|
-
task.export params['sql-file'],
|
|
24
|
-
path: params['dest-file'],
|
|
25
|
-
format: params['format'],
|
|
26
|
-
gzip: params['gzip'],
|
|
27
|
-
override: params['override']
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
require 'bricolage/datasource'
|
|
2
|
-
require 'bricolage/commandutils'
|
|
3
|
-
require 'stringio'
|
|
4
|
-
require 'date'
|
|
5
|
-
|
|
6
|
-
module Bricolage
|
|
7
|
-
|
|
8
|
-
class TDDataSource < DataSource
|
|
9
|
-
declare_type 'td'
|
|
10
|
-
|
|
11
|
-
include CommandUtils
|
|
12
|
-
|
|
13
|
-
def initialize(database: nil, username: nil, apikey: nil, td: 'td', priority: -2)
|
|
14
|
-
@database = database
|
|
15
|
-
@apikey = apikey
|
|
16
|
-
@td = td
|
|
17
|
-
@priority = priority
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def new_task
|
|
21
|
-
TDTask.new(self)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def query_command_args(*args)
|
|
25
|
-
[@td, "--apikey=#{@apikey}", "query", "--database=#{@database}", "--wait"] + args
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def delete_command_args(*args)
|
|
29
|
-
[@td, "--apikey=#{@apikey}", "table:partial_delete", @database, *args, "--wait"]
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def exec(*args)
|
|
33
|
-
JobResult.for_process_status(command(*args))
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
class TDTask < DataSourceTask
|
|
38
|
-
def export(stmt, path: nil, **opts)
|
|
39
|
-
add TDTask::Export.new(stmt, path: path, **opts)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
class Export < Action
|
|
43
|
-
include CommandUtils
|
|
44
|
-
|
|
45
|
-
def initialize(stmt, path: nil, format: nil, gzip: false, override: false)
|
|
46
|
-
@statement = stmt
|
|
47
|
-
@path = path
|
|
48
|
-
@format = format
|
|
49
|
-
@gzip = gzip
|
|
50
|
-
@override = override
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def_delegator '@statement', :bind
|
|
54
|
-
|
|
55
|
-
def source
|
|
56
|
-
buf = StringIO.new
|
|
57
|
-
buf.puts command_args(new_tmpfile_path).join(' ') + " <<EndTDSQL"
|
|
58
|
-
buf.puts @statement.stripped_source
|
|
59
|
-
buf.puts 'EndTDSQL'
|
|
60
|
-
buf.string
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
GZIP_COMMAND = 'gzip' # FIXME: parameterize
|
|
64
|
-
|
|
65
|
-
def run
|
|
66
|
-
if File.exist?(@path) and not @override
|
|
67
|
-
raise JobFailure, "target file exists: #{@path.inspect}"
|
|
68
|
-
end
|
|
69
|
-
puts @statement.source
|
|
70
|
-
td_result = make_tmpfile(@statement.stripped_source) {|query_path|
|
|
71
|
-
ds.exec(*command_args(query_path))
|
|
72
|
-
}
|
|
73
|
-
if @gzip
|
|
74
|
-
gzip_result = ds.command(GZIP_COMMAND, export_path)
|
|
75
|
-
raise JobFailure, "gzip failed" unless gzip_result.success?
|
|
76
|
-
end
|
|
77
|
-
td_result
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def command_args(query_path)
|
|
81
|
-
ds.query_command_args("--query=#{query_path}", "--output=#{export_path}", "--format=#{@format}")
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def export_path
|
|
85
|
-
@gzip ? @path.sub(/\.gz\z/, '') : @path
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def delete(table_name, **opts)
|
|
90
|
-
add TDTask::Delete.new(table_name, **opts)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
class Delete < Action
|
|
94
|
-
def initialize(table_name, from:, to:)
|
|
95
|
-
@table = table_name
|
|
96
|
-
@from = from.to_time.to_i
|
|
97
|
-
@to = to.to_time.to_i
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def run
|
|
101
|
-
td_result = ds.exec(source)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def command_args
|
|
105
|
-
ds.delete_command_args(@table, "--from #{@from}", "--to #{@to}")
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def source
|
|
109
|
-
buf = StringIO.new
|
|
110
|
-
buf.puts command_args.join(' ')
|
|
111
|
-
buf.string
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
end
|