mdbm_dist_support 0.2.1 → 0.2.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: 21076e79d83ad7a03a5039c335509dada5d31a6d
4
- data.tar.gz: 37e1553b71ff538727d31710863c102fe7e6aa65
3
+ metadata.gz: 63441d53fa1b5c25331d083b2b14a31020ba3cb2
4
+ data.tar.gz: 562d49c124a5a0eb065642eb39d69fc58a82d67b
5
5
  SHA512:
6
- metadata.gz: 25d3ce4e0f7ca1d7b71d926f100806167351c5e926f54dd4287d38461bc42d93c039327993313236ebfb944a20a1c721f84ae68449498aba1044dff0e03a2b13
7
- data.tar.gz: 4d2478659b15f95a094bde9dac555b451e664661e72da05f8097ecf9130ee6ee7934d9db9b7b55c95a0b46da35e618e08731509039133dc7925872b35c5de6e9
6
+ metadata.gz: d1216c13bb2ee5668842bd0855554dbc9313e0e03763a26946cc78722bee8c0a08462be0cacf0682c261b0d503a3f957706ff43f9334bac867b725e91730f8b0
7
+ data.tar.gz: 0d8666a66b5ab800f3851b4a2878fddc8781ba46ab9047e9760ee91425ff296f4187693c7647a9c7b4875f22d7877313955bb4f4aee52815ea8bcb4b883bef4a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mdbm_dist_support (0.2.1)
4
+ mdbm_dist_support (0.2.2)
5
5
  ruby-mdbm (>= 0.0.2)
6
6
 
7
7
  GEM
@@ -34,4 +34,4 @@ DEPENDENCIES
34
34
  rspec (~> 3.0)
35
35
 
36
36
  BUNDLED WITH
37
- 1.14.6
37
+ 1.15.4
data/README.md CHANGED
@@ -4,6 +4,10 @@ mdbm distribution support library gem
4
4
  [![Gem Version](https://badge.fury.io/rb/mdbm_dist_support.svg)](https://badge.fury.io/rb/mdbm_dist_support)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
 
7
+ ## Overview
8
+ When like below sequence, use this in BAT server.
9
+ ![overview image](https://github.com/MichinaoShimizu/mdbm_dist_support/blob/master/mdbm_dist.jpg?raw=true)
10
+
7
11
  ## Installation
8
12
  `gem install mdbm-dist-support`
9
13
 
@@ -17,8 +21,6 @@ Use like this.
17
21
  ### Sample
18
22
  #### update.rb
19
23
  ```ruby
20
- #!/usr/bin/env ruby
21
-
22
24
  require 'mdbm_dist_support'
23
25
 
24
26
  MdbmDistSupport::Distributer.new do |m|
@@ -27,22 +29,22 @@ MdbmDistSupport::Distributer.new do |m|
27
29
  m.local_path = '/tmp/hoge_local.mdbm'
28
30
  m.dist_path = '/tmp/hoge_dist.mdbm'
29
31
  m.cmd_print = '/tmp/print.rb'
30
- m.cmd_gen = '/usr/local/bin/i64_str_gen'
32
+ m.cmd_gen = :mdbm_store_func
31
33
  m.cmd_rep = '/usr/local/bin/mdbm_replace'
32
34
  m.full_mode = true
33
35
  m.dist_server_hosts = ['localhost']
34
36
  m.meta_incr_key = 'when_processed_fetched_max_date'
35
37
  end.run_dist
36
38
  ```
37
- #### required settings @run_dist
39
+ #### settings @run_dist
38
40
  |name|value|memo|
39
41
  |:-----------|:------------|:------------|
40
42
  |lock_path|local lock file path||
41
43
  |meta_path|local meta mdbm path||
42
44
  |local_path|local mdbm path||
43
45
  |dist_path|mdbm path in remote servers||
44
- |cmd_print|print command path|you need to make this command|
45
- |cmd_gen|generate mdbm command path|you need to make this command|
46
+ |cmd_print|print command path|need to make|
47
+ |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.|
46
48
  |cmd_rep|replace mdbm command path|[mdbm_replace](https://github.com/yahoo/mdbm/blob/master/gendoc/mdbm_replace.rst)|
47
49
  |full_mode|_true_: always update / _false_: when meta_incr_key is changed, do dist||
48
50
  |dist_server_hosts|distribute target server hosts array||
@@ -50,27 +52,21 @@ end.run_dist
50
52
 
51
53
  #### print.rb
52
54
  ```ruby
53
- #!/usr/bin/env ruby
54
-
55
55
  require 'mdbm_dist_support'
56
56
 
57
- # fetch data and print STDOUT KEY:VALUE set
58
57
  puts "1111111\tFUGAFUGA"
59
-
60
- # fetch db max-date or max id
61
58
  fetched_max_date = '2017-09-09 11:11:11'
62
59
 
63
- # print after, update meta increment val.
64
60
  MdbmDistSupport::Distributer.new do |m|
65
- m.meta_path = 'local meta mdbm file path'
61
+ m.meta_path = '/tmp/hoge_meta.mdbm'
66
62
  m.meta_incr_key = 'when_processed_fetched_max_date'
67
63
  end.run_print_after(fetched_max_date)
68
64
  ```
69
- #### required settings @run_print_after
70
- |name|value|memo|
71
- |:-----------|:------------|:------------|
72
- |meta_path|local meta mdbm path||
73
- |meta_incr_key|meta mdbm key (using increment update)||
65
+ #### settings @run_print_after
66
+ |name|value|
67
+ |:-----------|:------------|
68
+ |meta_path|local meta mdbm path|
69
+ |meta_incr_key|meta mdbm key (using increment update)|
74
70
 
75
71
  ## Requires
76
72
  * [mdbm](https://github.com/yahoo/mdbm)
@@ -3,6 +3,7 @@ require 'mdbm_dist_support/meta'
3
3
  require 'mdbm_dist_support/lock'
4
4
  require 'mdbm_dist_support/validator'
5
5
  require 'tempfile'
6
+ require 'mdbm'
6
7
 
7
8
  module MdbmDistSupport
8
9
  # Mdbm distributer
@@ -46,11 +47,23 @@ module MdbmDistSupport
46
47
  @@logger.info 'no need to update'
47
48
  break
48
49
  end
49
- cmd_exec %(cat #{f.path} | #{@cmd_gen} #{@local_path})
50
+ (@cmd_gen == :mdbm_store_func) ? do_mdbm_store(f) : do_outer_gen_cmd(f)
50
51
  dist
51
52
  end
52
53
  end
53
54
 
55
+ def do_mdbm_store(f)
56
+ f.each_line do |s|
57
+ kv = s.split("\t")
58
+ m = Mdbm.new(@local_path, Mdbm::MDBM_O_RDWR | Mdbm::MDBM_O_CREAT, 777, 0, 0)
59
+ m.store(kv[0], kv[1], Mdbm::MDBM_REPLACE)
60
+ end
61
+ end
62
+
63
+ def do_outer_gen_cmd(f)
64
+ cmd_exec %(cat #{f.path} | #{@cmd_gen} #{@local_path})
65
+ end
66
+
54
67
  def dist
55
68
  @dist_server_hosts.each do |s|
56
69
  cmd_exec %(scp -o StrictHostKeychecking=no #{@local_path} #{s}:#{@dist_path}.tmp)
@@ -1,3 +1,3 @@
1
1
  module MdbmDistSupport
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
data/mdbm_dist.jpg ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdbm_dist_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - MichinaoShimizu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-15 00:00:00.000000000 Z
11
+ date: 2017-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,6 +89,7 @@ files:
89
89
  - lib/mdbm_dist_support/meta.rb
90
90
  - lib/mdbm_dist_support/validator.rb
91
91
  - lib/mdbm_dist_support/version.rb
92
+ - mdbm_dist.jpg
92
93
  - mdbm_dist_support.gemspec
93
94
  homepage: https://github.com/MichinaoShimizu/mdbm_dist_support
94
95
  licenses: []