embulk-plugin-redis 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +19 -0
- data/README.md +32 -0
- data/Rakefile +4 -0
- data/embulk-plugin-redis.gemspec +21 -0
- data/lib/embulk/input_redis.rb +44 -0
- data/lib/embulk/output_redis.rb +56 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 61bf03fb439dda8470f34e9da531eb3cdca993ff
|
4
|
+
data.tar.gz: baff64f2a630fe88d3220bd281a1ad4e0fe9fca8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 71a2c46d0ae1631ca5bbbd414af8a7816557f12f2d881d485b2fdfd566e0a9790257f480c7e22307f674fbafcf3c66fb08564ee1033d705137cb7e87efc72d69
|
7
|
+
data.tar.gz: b488de53ecb598297f2035e58140c8bf015603bf822890a28bd20ecc76bc353fe5795b5b239980dd365a59d15dd27a2939524de3aadbe98a7bb47b4757087655
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
embulk-plugin-redis (0.1.0)
|
5
|
+
redis (>= 3.0.5)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
rake (10.4.2)
|
11
|
+
redis (3.0.7)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
bundler (~> 1.0)
|
18
|
+
embulk-plugin-redis!
|
19
|
+
rake (>= 0.9.2)
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Embulk input/output plugin for Redis
|
2
|
+
|
3
|
+
This [Embulk](https://github.com/embulk/embulk) output plugin writes records to a json column of a table.
|
4
|
+
|
5
|
+
This plugin runs without transaction for now.
|
6
|
+
|
7
|
+
## Configuration
|
8
|
+
|
9
|
+
- **host** host name of the Redis server (string, default: "localhost")
|
10
|
+
- **port** port of the Redis server (integer, default: 6379)
|
11
|
+
- **db** destination database number (integer, default: 0)
|
12
|
+
- **key_prefix** key prefix to search keys for input plugin (string)
|
13
|
+
- **key** key name for output plugin (string, required)
|
14
|
+
|
15
|
+
### Example
|
16
|
+
|
17
|
+
```yaml
|
18
|
+
out:
|
19
|
+
type: redis
|
20
|
+
host: localhost
|
21
|
+
port: 6379
|
22
|
+
db: 0
|
23
|
+
key: user_name
|
24
|
+
|
25
|
+
in:
|
26
|
+
type: redis
|
27
|
+
host: localhost
|
28
|
+
port: 6379
|
29
|
+
db: 0
|
30
|
+
key_prefix: user_
|
31
|
+
```
|
32
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
Gem::Specification.new do |gem|
|
3
|
+
gem.name = "embulk-plugin-redis"
|
4
|
+
gem.version = "0.1.0"
|
5
|
+
|
6
|
+
gem.summary = %q{Embulk plugin for Redis}
|
7
|
+
gem.description = gem.summary
|
8
|
+
gem.authors = ["Mitsunori Komatsu"]
|
9
|
+
gem.email = ["komamitsu@gmail.com"]
|
10
|
+
gem.license = "Apache 2.0"
|
11
|
+
gem.homepage = "https://github.com/komamitsu/embulk-plugin-redis"
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.has_rdoc = false
|
17
|
+
|
18
|
+
gem.add_dependency 'redis', ['>= 3.0.5']
|
19
|
+
gem.add_development_dependency 'bundler', ['~> 1.0']
|
20
|
+
gem.add_development_dependency 'rake', ['>= 0.9.2']
|
21
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Embulk
|
2
|
+
|
3
|
+
class InputRedis < InputPlugin
|
4
|
+
require 'redis'
|
5
|
+
|
6
|
+
Plugin.register_input('redis', self)
|
7
|
+
|
8
|
+
def self.transaction(config, &control)
|
9
|
+
task = {
|
10
|
+
'host' => config.param('host', :string, :default => 'localhost'),
|
11
|
+
'port' => config.param('port', :int, :default => 6379),
|
12
|
+
'db' => config.param('db', :int, :default => 0),
|
13
|
+
'key_prefix' => config.param('key_prefix', :string, :default => ''),
|
14
|
+
}
|
15
|
+
threads = config.param('threads', :int, default: 1)
|
16
|
+
|
17
|
+
columns = [
|
18
|
+
Column.new(0, 'key', :string),
|
19
|
+
Column.new(1, 'value', :string),
|
20
|
+
]
|
21
|
+
|
22
|
+
puts "Redis input started."
|
23
|
+
commit_reports = yield(task, columns, threads)
|
24
|
+
puts "Redis input finished. Commit reports = #{commit_reports.to_json}"
|
25
|
+
|
26
|
+
return {}
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.run(task, schema, index, page_builder)
|
30
|
+
puts "Redis input thread #{index}..."
|
31
|
+
|
32
|
+
r = ::Redis.new(:host => task['host'], :port => task['port'], :db => task['db'])
|
33
|
+
r.keys("#{task['key_prefix']}*").each do |k|
|
34
|
+
page_builder.add([k, r.get(k)])
|
35
|
+
end
|
36
|
+
page_builder.finish # don't forget to call finish :-)
|
37
|
+
|
38
|
+
commit_report = {
|
39
|
+
}
|
40
|
+
return commit_report
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Embulk
|
2
|
+
|
3
|
+
class OutputRedis < OutputPlugin
|
4
|
+
require 'redis'
|
5
|
+
|
6
|
+
Plugin.register_output('redis', self)
|
7
|
+
|
8
|
+
def self.transaction(config, schema, processor_count, &control)
|
9
|
+
task = {
|
10
|
+
'host' => config.param('host', :string, :default => 'localhost'),
|
11
|
+
'port' => config.param('port', :int, :default => 6379),
|
12
|
+
'db' => config.param('db', :int, :default => 0),
|
13
|
+
'key' => config.param('key', :string),
|
14
|
+
}
|
15
|
+
|
16
|
+
puts "Redis output started."
|
17
|
+
commit_reports = yield(task)
|
18
|
+
puts "Redis output finished. Commit reports = #{commit_reports.to_json}"
|
19
|
+
|
20
|
+
return {}
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(task, schema, index)
|
24
|
+
puts "Example output thread #{index}..."
|
25
|
+
super
|
26
|
+
@records = 0
|
27
|
+
@redis = ::Redis.new(:host => task['host'], :port => task['port'], :db => task['db'])
|
28
|
+
end
|
29
|
+
|
30
|
+
def close
|
31
|
+
end
|
32
|
+
|
33
|
+
def add(page)
|
34
|
+
page.each do |record|
|
35
|
+
hash = Hash[schema.names.zip(record)]
|
36
|
+
puts "#{@message}: #{hash.to_json}"
|
37
|
+
@redis.set(hash[task['key']], hash)
|
38
|
+
@records += 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def finish
|
43
|
+
end
|
44
|
+
|
45
|
+
def abort
|
46
|
+
end
|
47
|
+
|
48
|
+
def commit
|
49
|
+
commit_report = {
|
50
|
+
"records" => @records
|
51
|
+
}
|
52
|
+
return commit_report
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-plugin-redis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mitsunori Komatsu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: redis
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.9.2
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.9.2
|
55
|
+
description: Embulk plugin for Redis
|
56
|
+
email:
|
57
|
+
- komamitsu@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- Gemfile.lock
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- embulk-plugin-redis.gemspec
|
67
|
+
- lib/embulk/input_redis.rb
|
68
|
+
- lib/embulk/output_redis.rb
|
69
|
+
homepage: https://github.com/komamitsu/embulk-plugin-redis
|
70
|
+
licenses:
|
71
|
+
- Apache 2.0
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.0.14
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Embulk plugin for Redis
|
93
|
+
test_files: []
|
94
|
+
has_rdoc: false
|