samidare 0.1.1 → 0.1.2

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: a49b357549f688374b83430a5d40df45496c19b4
4
- data.tar.gz: a3fc947687f91c83ee68e5b9779c11a7cf090be2
3
+ metadata.gz: f97f6368bca22b657df37c1279d7b5d07c514c76
4
+ data.tar.gz: 62f4b01e91cfda7c95b787e71a047e5d8fb2155f
5
5
  SHA512:
6
- metadata.gz: badbd61dc8ef4cad55673a9accc4b979715525a7e7660f25f03eb795b0beb6b6f395dbf0b9484358048687244b2efb0cc0f5542148517396ae3566387845395c
7
- data.tar.gz: 3557f97222c151e550fb27416edffd7b398b58519b9f51c06692acaf00eb132ef834397edb9c47a1d74c83388a013b2ff5541a3f03372f48515ff4a62f7c6f58
6
+ metadata.gz: 64dde2e0f6fd33eae7b2d044acabe546ee097745617410a751b6dfa48e3fd8bd8389d80e820037ec876b299e74637ef6ea1db22dbe56e793b3a55c533e7ef166
7
+ data.tar.gz: 1c687b2b61a237444ce5d7e9f1dbf44d73985482a0ef8d31178806a1321a11224b97277d756c26ffffb891f87689e57335e0772ae913340805a5418c77b14ada
@@ -9,19 +9,34 @@ module Samidare
9
9
  Samidare::EmbulkUtility::ConfigGenerator.new.generate_config(database_configs, bq_config)
10
10
  end
11
11
 
12
- def run(bq_config, target_table_names = [])
12
+ def run(bq_config, target_table_names = [], retry_max = 0)
13
+ error_tables = run_and_retry(bq_config, target_table_names, retry_max, 0)
14
+ # return batch status(true: all tables success)
15
+ error_tables.size == 0
16
+ end
17
+
18
+ private
19
+ def run_and_retry(bq_config, target_table_names = [], retry_max, retry_count)
13
20
  error_tables = Samidare::Embulk.new.run(
14
21
  database_configs,
15
- Samidare::MySQL::TableConfig.generate_table_configs,
22
+ table_configs,
16
23
  bq_config,
17
24
  target_table_names)
18
- # return batch status(true: all tables success)
19
- error_tables.size == 0
25
+ if error_tables.size > 0 && retry_count < retry_max
26
+ puts "------------------------------------"
27
+ puts "retry start -> #{retry_count + 1} time"
28
+ puts "------------------------------------"
29
+ error_tables = run_and_retry(bq_config, error_tables, retry_max, retry_count + 1)
30
+ end
31
+ error_tables
20
32
  end
21
33
 
22
- private
23
34
  def database_configs
24
- YAML.load_file('database.yml')
35
+ @database_configs ||= YAML.load_file('database.yml')
36
+ end
37
+
38
+ def table_configs
39
+ @table_configs ||= Samidare::MySQL::TableConfig.generate_table_configs
25
40
  end
26
41
  end
27
42
  end
@@ -1,3 +1,3 @@
1
1
  module Samidare
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samidare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryoji Kobori
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-31 00:00:00.000000000 Z
11
+ date: 2016-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler