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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +14 -18
- data/lib/mdbm_dist_support/distributer.rb +14 -1
- data/lib/mdbm_dist_support/version.rb +1 -1
- data/mdbm_dist.jpg +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63441d53fa1b5c25331d083b2b14a31020ba3cb2
|
4
|
+
data.tar.gz: 562d49c124a5a0eb065642eb39d69fc58a82d67b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1216c13bb2ee5668842bd0855554dbc9313e0e03763a26946cc78722bee8c0a08462be0cacf0682c261b0d503a3f957706ff43f9334bac867b725e91730f8b0
|
7
|
+
data.tar.gz: 0d8666a66b5ab800f3851b4a2878fddc8781ba46ab9047e9760ee91425ff296f4187693c7647a9c7b4875f22d7877313955bb4f4aee52815ea8bcb4b883bef4a
|
data/Gemfile.lock
CHANGED
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 =
|
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
|
-
####
|
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|
|
45
|
-
|cmd_gen|generate mdbm command path|
|
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
|
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
|
-
####
|
70
|
-
|name|value|
|
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
|
-
|
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)
|
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.
|
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-
|
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: []
|