mdbm_dist_support 0.2.4 → 0.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ff37bbd0dbe3ea23a0ea546be38c5cdbcfc945c
4
- data.tar.gz: a903917387151b34e8f38bf9f2ea0633259795f4
3
+ metadata.gz: dd99e670304709edfb7535cc8196413064bd9ed6
4
+ data.tar.gz: a7c4284c3eb2f223955698bf9f3072c412f2a7a0
5
5
  SHA512:
6
- metadata.gz: 169eff5558f9c64159b28a5031d2f8250c242fd18ac12171041a6a1df8b4abbcb9738d2b3bd0de00cf7f4943229e9d58ff11bea18c8f5c9b3b51374d53ef417e
7
- data.tar.gz: 72ad82c2c5b788a3e9c5d5355a474f7d82d265843aa39b28850db9df63adce08abd15437e3ef9af76ae1750f3c81b2b8d1e0ed8255fdf447ee5b0811888ae95e
6
+ metadata.gz: 19700472b943e42ee7a8bfa3a0ec8ad3c658c45401949719db4e38b3eb20bd2aef424358b0458983a8a551b544ee35e6f6dd41243459608e1a236ea0a8b6f222
7
+ data.tar.gz: 3820d6ca97378d15905d57c477e2eef6f431877aa71c1c37b52f0dc9f7e633aadaba961d79868c5a7c25a865efe78a92bc9edb50cd033da0b695f37bd764b029
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mdbm_dist_support (0.2.4)
4
+ mdbm_dist_support (0.2.5)
5
5
  ruby-mdbm (>= 0.0.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -37,7 +37,6 @@ MdbmDistSupport::Distributer.new do |m|
37
37
  :host => 'remote2', :port => 22, :user => 'hee', :key => '/home/hee/.ssh/id_rsa',
38
38
  :host => 'remote3', :port => 22, :user => 'hyo', :key => '/home/hyo/.ssh/id_rsa',
39
39
  ]
40
- m.meta_incr_key = 'when_processed_fetched_max_date'
41
40
  end.run_dist
42
41
  ```
43
42
  #### settings @run_dist
@@ -50,27 +49,24 @@ end.run_dist
50
49
  |cmd_print|print command path|need to make|
51
50
  |cmd_gen|generate mdbm command path or `:mdbm_store_func`|need to make if you want to generate mdbm othert than _String:String_ set like _int64:String_, _int32:int64_.if you set `:mdbm_store_func` only, set use mdbm.stroe() function.|
52
51
  |cmd_rep|replace mdbm command path|[mdbm_replace](https://github.com/yahoo/mdbm/blob/master/gendoc/mdbm_replace.rst)|
53
- |full_mode|`true`: full `false`: incremental||
52
+ |full_mode|`true`: full `false`: inc|when you set `false`, distribute when `meta_mdbm_increment_key` key in meta was updated only.|
54
53
  |dist_servers|distribute server info array||
55
- |meta_incr_key|meta mdbm key using incremental mode||
56
54
 
57
55
  #### print.rb
58
56
  ```ruby
59
57
  require 'mdbm_dist_support'
60
58
 
61
59
  puts "1111111\tFUGAFUGA"
62
- fetched_max_date = '2017-09-09 11:11:11'
60
+ inc_key = '2017-09-09 11:11:11'
63
61
 
64
62
  MdbmDistSupport::Distributer.new do |m|
65
- m.meta_path = '/tmp/hoge_meta.mdbm'
66
- m.meta_incr_key = 'when_processed_fetched_max_date'
67
- end.run_print_after(fetched_max_date)
63
+ m.meta_path = '/tmp/hoge_meta.mdbm'
64
+ end.run_print_after(inc_key)
68
65
  ```
69
66
  #### settings @run_print_after
70
67
  |name|value|
71
68
  |:-----------|:------------|
72
69
  |meta_path|meta mdbm path|
73
- |meta_incr_key|meta mdbm key using incremental mode|
74
70
 
75
71
  ## Requires
76
72
  * [mdbm](https://github.com/yahoo/mdbm)
@@ -8,9 +8,10 @@ require 'mdbm'
8
8
  module MdbmDistSupport
9
9
  # Mdbm distributer
10
10
  class Distributer
11
+ INCR_KEY = 'meta_mdbm_increment_key'.freeze
11
12
  attr_accessor :lock_path, :meta_path, :meta, :local_path,\
12
13
  :dist_path, :cmd_print, :cmd_gen, :cmd_rep,\
13
- :dist_servers, :meta_incr_key, :full_mode
14
+ :dist_servers, :full_mode
14
15
 
15
16
  include MdbmDistSupport::CustomLogger
16
17
 
@@ -29,16 +30,16 @@ module MdbmDistSupport
29
30
 
30
31
  def run_print_after(meta_val)
31
32
  raise 'validate error' unless MdbmDistSupport::Validator.valid_run_print_after_settings?(instance_variables)
32
- @meta.store(@meta_incr_key, meta_val)
33
+ @meta.store(INCR_KEY, meta_val)
33
34
  end
34
35
 
35
36
  private
36
37
 
37
38
  def local_up
38
39
  Tempfile.create('mdbm_dist_support') do |f|
39
- date_b = @meta.fetch(@meta_incr_key)
40
+ date_b = @meta.fetch(INCR_KEY)
40
41
  cmd_exec %(#{@cmd_print} > #{f.path})
41
- date_a = @meta.fetch(@meta_incr_key)
42
+ date_a = @meta.fetch(INCR_KEY)
42
43
  if @full_mode == false && date_a == date_b
43
44
  @@logger.info 'no need to update'
44
45
  break
@@ -49,7 +50,7 @@ module MdbmDistSupport
49
50
 
50
51
  def do_mdbm_store(f)
51
52
  f.each_line do |s|
52
- kv = s.split("\t")
53
+ kv = s.chomp.split("\t")
53
54
  m = Mdbm.new(@local_path, Mdbm::MDBM_O_RDWR | Mdbm::MDBM_O_CREAT, 0644, 0, 0)
54
55
  m.store(kv[0], kv[1], Mdbm::MDBM_REPLACE)
55
56
  end
@@ -5,11 +5,10 @@ module MdbmDistSupport
5
5
  class Validator
6
6
  RUN_DIST_REQUIRE_INSTANCE_VARS =
7
7
  %i[@lock_path @meta_path @local_path @dist_path @cmd_print
8
- @cmd_gen @cmd_rep @full_mode @dist_servers
9
- @meta_incr_key].freeze
8
+ @cmd_gen @cmd_rep @full_mode @dist_servers].freeze
10
9
 
11
10
  RUN_PRINT_AFTER_REQUIRE_INSTANCE_VARS =
12
- %i[@meta_path @meta_incr_key].freeze
11
+ %i[@meta_path].freeze
13
12
 
14
13
  include MdbmDistSupport::CustomLogger
15
14
 
@@ -1,3 +1,3 @@
1
1
  module MdbmDistSupport
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
data/update.rb ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ require 'mdbm_dist_support'
3
+
4
+ MdbmDistSupport::Distributer.new do |m|
5
+ m.lock_path = '/tmp/hoge.lck'
6
+ m.meta_path = '/tmp/hoge_meta.mdbm'
7
+ m.local_path = '/tmp/hoge_local.mdbm'
8
+ m.dist_path = '/tmp/hoge_dist.mdbm'
9
+ m.cmd_print = '/tmp/print.rb'
10
+ m.cmd_gen = :mdbm_store_func
11
+ m.cmd_rep = '/usr/local/bin/mdbm_replace'
12
+ m.full_mode = true
13
+ m.dist_servers = [ :host => 'localhost', :port => 61204, :user => 'shimizu', :key => '/home/shimizu/.ssh/id_rsa.bk']
14
+ end.run_dist
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdbm_dist_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - MichinaoShimizu
@@ -91,6 +91,7 @@ files:
91
91
  - lib/mdbm_dist_support/version.rb
92
92
  - mdbm_dist.jpg
93
93
  - mdbm_dist_support.gemspec
94
+ - update.rb
94
95
  homepage: https://github.com/MichinaoShimizu/mdbm_dist_support
95
96
  licenses: []
96
97
  metadata: {}