bricolage 5.18.1 → 5.19.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e09f9be942c6431360ac3ec8afbd9cae5c03b06
|
4
|
+
data.tar.gz: b9c2dc9c5a91b42b0e60fb43c089b12f58670128
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be674ea50692704964d7360c35092e116078b5fb03ac0d2e2f620eb9abb083ffbc9a335d384e4f1c5a68594da4ff00e528097f707da6e03a2925e20a015fe7b5
|
7
|
+
data.tar.gz: 69241018dcfa1862b327bcc9d43404890b91bc38bcd57836b5a34187507318a3ba9907de33534fef15c606bc01a08e5f4cd6d70ba2c0e0215d9614f5005af7fb
|
@@ -5,6 +5,7 @@ require 'bricolage/jobresult'
|
|
5
5
|
require 'bricolage/variables'
|
6
6
|
require 'bricolage/datasource'
|
7
7
|
require 'bricolage/eventhandlers'
|
8
|
+
require 'bricolage/postgresconnection'
|
8
9
|
require 'bricolage/logger'
|
9
10
|
require 'bricolage/exception'
|
10
11
|
require 'bricolage/version'
|
@@ -14,12 +15,17 @@ require 'optparse'
|
|
14
15
|
module Bricolage
|
15
16
|
|
16
17
|
class Application
|
18
|
+
def Application.install_signal_handlers
|
19
|
+
Signal.trap('PIPE', 'IGNORE')
|
20
|
+
PostgresConnection.install_signal_handlers
|
21
|
+
end
|
22
|
+
|
17
23
|
def Application.main
|
24
|
+
install_signal_handlers
|
18
25
|
new.main
|
19
26
|
end
|
20
27
|
|
21
28
|
def initialize
|
22
|
-
Signal.trap('PIPE', 'IGNORE')
|
23
29
|
@hooks = Bricolage
|
24
30
|
end
|
25
31
|
|
@@ -17,11 +17,11 @@ module Bricolage
|
|
17
17
|
|
18
18
|
class JobNetRunner
|
19
19
|
def JobNetRunner.main
|
20
|
+
Application.install_signal_handlers
|
20
21
|
new.main
|
21
22
|
end
|
22
23
|
|
23
24
|
def initialize
|
24
|
-
Signal.trap('PIPE', 'IGNORE')
|
25
25
|
@hooks = ::Bricolage
|
26
26
|
@jobnet_id = nil
|
27
27
|
@jobnet_start_time = Time.now
|
@@ -7,6 +7,13 @@ module Bricolage
|
|
7
7
|
|
8
8
|
class PostgresConnection
|
9
9
|
|
10
|
+
def PostgresConnection.install_signal_handlers
|
11
|
+
Signal.trap(:TERM) {
|
12
|
+
$stderr.puts 'receive SIGTERM'
|
13
|
+
raise Interrupt, 'SIGTERM'
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
10
17
|
def PostgresConnection.open_data_source(ds)
|
11
18
|
conn = _open_ds(ds)
|
12
19
|
if block_given?
|
@@ -54,19 +61,46 @@ module Bricolage
|
|
54
61
|
@closed
|
55
62
|
end
|
56
63
|
|
64
|
+
def cancel_force
|
65
|
+
cancel
|
66
|
+
rescue PostgreSQLException
|
67
|
+
end
|
68
|
+
|
69
|
+
def cancel
|
70
|
+
@logger.info "cancelling PostgreSQL query..."
|
71
|
+
err = @connection.cancel
|
72
|
+
if err
|
73
|
+
@logger.error "could not cancel query: #{err}"
|
74
|
+
raise PostgreSQLException, "could not cancel query: #{err}"
|
75
|
+
else
|
76
|
+
@logger.info "successfully cancelled"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def querying
|
81
|
+
return yield
|
82
|
+
rescue Interrupt
|
83
|
+
@logger.info "query interrupted"
|
84
|
+
cancel_force
|
85
|
+
raise
|
86
|
+
end
|
87
|
+
private :querying
|
88
|
+
|
57
89
|
def execute_update(query)
|
58
90
|
log_query query
|
59
91
|
rs = log_elapsed_time {
|
60
|
-
|
92
|
+
querying {
|
93
|
+
@connection.async_exec(query)
|
94
|
+
}
|
61
95
|
}
|
62
|
-
|
63
|
-
rs.clear
|
64
|
-
result
|
96
|
+
return rs.to_a
|
65
97
|
rescue PG::ConnectionBad, PG::UnableToSend => ex
|
66
98
|
@connection_failed = true
|
67
99
|
raise ConnectionError.wrap(ex)
|
68
100
|
rescue PG::Error => ex
|
69
101
|
raise PostgreSQLException.wrap(ex)
|
102
|
+
ensure
|
103
|
+
rs.clear if rs
|
70
104
|
end
|
71
105
|
|
72
106
|
alias execute execute_update
|
@@ -89,19 +123,25 @@ module Bricolage
|
|
89
123
|
execute_query(query) {|rs| rs.to_a.first }
|
90
124
|
end
|
91
125
|
|
126
|
+
def query_rows(query)
|
127
|
+
execute_query(query) {|rs| rs.to_a }
|
128
|
+
end
|
129
|
+
|
92
130
|
def execute_query(query, &block)
|
93
131
|
log_query query
|
94
132
|
rs = log_elapsed_time {
|
95
|
-
|
133
|
+
querying {
|
134
|
+
@connection.async_exec(query)
|
135
|
+
}
|
96
136
|
}
|
97
|
-
|
98
|
-
rs.clear
|
99
|
-
result
|
137
|
+
return (yield rs)
|
100
138
|
rescue PG::ConnectionBad, PG::UnableToSend => ex
|
101
139
|
@connection_failed = true
|
102
140
|
raise ConnectionError.wrap(ex)
|
103
141
|
rescue PG::Error => ex
|
104
142
|
raise PostgreSQLException.wrap(ex)
|
143
|
+
ensure
|
144
|
+
rs.clear if rs
|
105
145
|
end
|
106
146
|
|
107
147
|
alias query execute_query
|
@@ -112,27 +152,6 @@ module Bricolage
|
|
112
152
|
}
|
113
153
|
end
|
114
154
|
|
115
|
-
def streaming_execute_query(query, &block)
|
116
|
-
log_query query
|
117
|
-
log_elapsed_time {
|
118
|
-
@connection.send_query(query)
|
119
|
-
}
|
120
|
-
@connection.set_single_row_mode
|
121
|
-
while rs = @connection.get_result
|
122
|
-
begin
|
123
|
-
rs.check
|
124
|
-
yield rs
|
125
|
-
ensure
|
126
|
-
rs.clear
|
127
|
-
end
|
128
|
-
end
|
129
|
-
rescue PG::ConnectionBad, PG::UnableToSend => ex
|
130
|
-
@connection_failed = true
|
131
|
-
raise ConnectionError.wrap(ex)
|
132
|
-
rescue PG::Error => ex
|
133
|
-
raise PostgreSQLException.wrap(ex)
|
134
|
-
end
|
135
|
-
|
136
155
|
def in_transaction?
|
137
156
|
@connection.transaction_status == PG::Constants::PQTRANS_INTRANS
|
138
157
|
end
|
data/lib/bricolage/version.rb
CHANGED
data/test/home/Gemfile.lock
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bricolage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minero Aoki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|