embulk-plugin-redis-url 0.2.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 +22 -0
- data/README.md +32 -0
- data/Rakefile +4 -0
- data/embulk-plugin-redis.gemspec +21 -0
- data/lib/embulk/input_redis.rb +50 -0
- data/lib/embulk/output_redis.rb +61 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bb328779e704f4e33b0411e31c82853c4638f707
|
4
|
+
data.tar.gz: 9348bb1c7a323d783679a2141a41ba8d393b239d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 65e36ae751469c2e37199c091f29c8e2d05d1fc5645d3d1c9f68c3b4fa86fd787fdee4b35800d2bad9bf9b3b6cca55cfe48a075e86e796368da1c61aca08a135
|
7
|
+
data.tar.gz: bbf9df820775e7ba898320f667a75060fec1ff5bc4af5400fe83e72b1a63135e24a2e6dbef3fb66bb1c6a50e5d94291a4e2e9dbc26c2bd3229d71cdd45f63d3b
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
embulk-plugin-redis-url (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-url!
|
19
|
+
rake (>= 0.9.2)
|
20
|
+
|
21
|
+
BUNDLED WITH
|
22
|
+
1.11.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-url"
|
4
|
+
gem.version = "0.2.0"
|
5
|
+
|
6
|
+
gem.summary = %q{Embulk plugin for Redis (with URL connection string support)}
|
7
|
+
gem.description = gem.summary
|
8
|
+
gem.authors = ["Mitsunori Komatsu", "Tom Maiaroto"]
|
9
|
+
gem.email = ["komamitsu@gmail.com", "tom@funnelenvy.com"]
|
10
|
+
gem.license = "Apache 2.0"
|
11
|
+
gem.homepage = "https://github.com/FunnelEnvy/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,50 @@
|
|
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
|
+
'url' => config.param('url', :string),
|
15
|
+
}
|
16
|
+
threads = config.param('threads', :int, default: 1)
|
17
|
+
|
18
|
+
columns = [
|
19
|
+
Column.new(0, 'key', :string),
|
20
|
+
Column.new(1, 'value', :string),
|
21
|
+
]
|
22
|
+
|
23
|
+
puts "Redis input started."
|
24
|
+
commit_reports = yield(task, columns, threads)
|
25
|
+
puts "Redis input finished. Commit reports = #{commit_reports.to_json}"
|
26
|
+
|
27
|
+
return {}
|
28
|
+
end
|
29
|
+
|
30
|
+
def run
|
31
|
+
puts "Redis input thread #{@index}..."
|
32
|
+
|
33
|
+
if @task['url'].nil? || @task['url'].empty?
|
34
|
+
r = ::Redis.new(:host => @task['host'], :port => @task['port'], :db => @task['db'])
|
35
|
+
else
|
36
|
+
r = ::Redis.new(:url => @task['url'])
|
37
|
+
end
|
38
|
+
|
39
|
+
r.keys("#{@task['key_prefix']}*").each do |k|
|
40
|
+
@page_builder.add([k, r.get(k)])
|
41
|
+
end
|
42
|
+
@page_builder.finish # don't forget to call finish :-)
|
43
|
+
|
44
|
+
commit_report = {
|
45
|
+
}
|
46
|
+
return commit_report
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,61 @@
|
|
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
|
+
'url' => config.param('url', :string),
|
15
|
+
}
|
16
|
+
|
17
|
+
puts "Redis output started."
|
18
|
+
commit_reports = yield(task)
|
19
|
+
puts "Redis output finished. Commit reports = #{commit_reports.to_json}"
|
20
|
+
|
21
|
+
return {}
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(task, schema, index)
|
25
|
+
puts "Example output thread #{index}..."
|
26
|
+
super
|
27
|
+
@records = 0
|
28
|
+
if task['url'].nil? || task['url'].empty?
|
29
|
+
@redis = ::Redis.new(:host => task['host'], :port => task['port'], :db => task['db'])
|
30
|
+
else
|
31
|
+
@redis = ::Redis.new(:url => task['url'])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def close
|
36
|
+
end
|
37
|
+
|
38
|
+
def add(page)
|
39
|
+
page.each do |record|
|
40
|
+
hash = Hash[schema.names.zip(record)]
|
41
|
+
puts "#{@message}: #{hash.to_json}"
|
42
|
+
@redis.set(hash[task['key']], hash)
|
43
|
+
@records += 1
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def finish
|
48
|
+
end
|
49
|
+
|
50
|
+
def abort
|
51
|
+
end
|
52
|
+
|
53
|
+
def commit
|
54
|
+
commit_report = {
|
55
|
+
"records" => @records
|
56
|
+
}
|
57
|
+
return commit_report
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-plugin-redis-url
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mitsunori Komatsu
|
8
|
+
- Tom Maiaroto
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-04-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: redis
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 3.0.5
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 3.0.5
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.9.2
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.9.2
|
56
|
+
description: Embulk plugin for Redis (with URL connection string support)
|
57
|
+
email:
|
58
|
+
- komamitsu@gmail.com
|
59
|
+
- tom@funnelenvy.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- embulk-plugin-redis.gemspec
|
69
|
+
- lib/embulk/input_redis.rb
|
70
|
+
- lib/embulk/output_redis.rb
|
71
|
+
homepage: https://github.com/FunnelEnvy/embulk-plugin-redis
|
72
|
+
licenses:
|
73
|
+
- Apache 2.0
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.2.2
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Embulk plugin for Redis (with URL connection string support)
|
95
|
+
test_files: []
|