embulk-input-buildkite 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -0
- data/docker-compose.yml +2 -1
- data/embulk-input-buildkite.gemspec +1 -1
- data/lib/embulk/input/buildkite.rb +42 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ad00bb2939704ea96a218b7825190027e7fe47c44cc9a5fad3128805e728360
|
4
|
+
data.tar.gz: afcc34e688f3bee95aeb78d5d4d0d29cbac22ab372b12cdd034cf29a0b0cfc6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4a0161cb327a962851529d364f426672bbd277e147eacdc4974ffc22574519b2440a414c98936b12452242f542cb5184e5597af11eb0a95d62cdc69fb0290cd
|
7
|
+
data.tar.gz: 067a7064167107a9999d348ddc711fc6764102751d0363b8f8261e802629c49be7797fac331b889b14087c3b135db487c348ddac841270a9e78353d566a23af6
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -15,6 +15,7 @@ Fetch Buildkite build results
|
|
15
15
|
- **pipeline_slug**: Target pipeline name like `rails` (string, required)
|
16
16
|
- **build_nums**: Build numbers (Array of integer, required)
|
17
17
|
- **token**: Buildkite API token which can be found on https://buildkite.com/user/api-access-tokens (string, required)
|
18
|
+
- **artifact_download_concurrency**: Artifact download concurrency (integer, optional, default: 10)
|
18
19
|
|
19
20
|
## Example
|
20
21
|
|
data/docker-compose.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = "embulk-input-buildkite"
|
4
|
-
spec.version = "0.
|
4
|
+
spec.version = "0.4.0"
|
5
5
|
spec.authors = ["Fumiaki MATSUSHIMA"]
|
6
6
|
spec.summary = "Buildkite input plugin for Embulk"
|
7
7
|
spec.description = "Loads records from Buildkite."
|
@@ -4,13 +4,17 @@ module Embulk
|
|
4
4
|
module Input
|
5
5
|
|
6
6
|
class Buildkite < InputPlugin
|
7
|
+
MAX_RETRY = 5
|
8
|
+
|
7
9
|
class Logger
|
8
10
|
def initialize(embulk_logger)
|
9
11
|
@embulk_logger = embulk_logger
|
10
12
|
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
%w(info warn error).each do |m|
|
15
|
+
define_method(m) do |message|
|
16
|
+
@embulk_logger.send(m, "embulk-input-buildkite: #{message}")
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
@@ -22,7 +26,8 @@ module Embulk
|
|
22
26
|
"org_slug" => config.param("org_slug", :string),
|
23
27
|
"pipeline_slug" => config.param("pipeline_slug", :string),
|
24
28
|
"build_nums" => config.param("build_nums", :array),
|
25
|
-
"token" => config.param("token", :string
|
29
|
+
"token" => config.param("token", :string),
|
30
|
+
"artifact_download_concurrency" => config.param("artifact_download_concurrency", :integer, default: 10),
|
26
31
|
}
|
27
32
|
|
28
33
|
columns = [
|
@@ -63,14 +68,25 @@ module Embulk
|
|
63
68
|
task['build_nums'].each do |build_num|
|
64
69
|
logger.info("Start build_num:[#{build_num}]")
|
65
70
|
|
66
|
-
build = client.fetch_build(number: build_num)
|
71
|
+
build = with_retry { client.fetch_build(number: build_num) }
|
67
72
|
build[:jobs].each do |job|
|
68
73
|
logger.info("Start Start job_id:[#{job[:id]}]")
|
69
|
-
log = client.fetch_log(build_number: job[:build_number], job_id: job[:id])
|
70
|
-
artifacts = client.fetch_artifacts(build_number: job[:build_number], job_id: job[:id])
|
71
|
-
|
72
|
-
|
74
|
+
log = with_retry { client.fetch_log(build_number: job[:build_number], job_id: job[:id]) }
|
75
|
+
artifacts = with_retry { client.fetch_artifacts(build_number: job[:build_number], job_id: job[:id]) }
|
76
|
+
|
77
|
+
queue = Queue.new
|
78
|
+
artifacts.each {|a| queue.push(a) }
|
79
|
+
workers = Array.new(task['artifact_download_concurrency']) do
|
80
|
+
Thread.new do
|
81
|
+
begin
|
82
|
+
while artifact = queue.pop(true)
|
83
|
+
artifact[:body] = with_retry { client.fetch_artifact(build_number: job[:build_number], job_id: job[:id], artifact_id: artifact[:id]) }
|
84
|
+
end
|
85
|
+
rescue ThreadError
|
86
|
+
end
|
87
|
+
end
|
73
88
|
end
|
89
|
+
workers.each(&:join)
|
74
90
|
|
75
91
|
page_builder.add([
|
76
92
|
job[:id],
|
@@ -101,6 +117,24 @@ module Embulk
|
|
101
117
|
def logger
|
102
118
|
@logger ||= Logger.new(Embulk.logger)
|
103
119
|
end
|
120
|
+
|
121
|
+
def with_retry(&block)
|
122
|
+
retries = 0
|
123
|
+
begin
|
124
|
+
yield
|
125
|
+
rescue => e
|
126
|
+
sleep retries
|
127
|
+
|
128
|
+
if retries < MAX_RETRY
|
129
|
+
retries += 1
|
130
|
+
logger.warn("retry ##{retries}, #{e.message}")
|
131
|
+
retry
|
132
|
+
else
|
133
|
+
logger.error("retry exhausted ##{retries}, #{e.message}")
|
134
|
+
raise e
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
104
138
|
end
|
105
139
|
|
106
140
|
end
|