embulk-input-redis_custom_restock_noti 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bee0463925a41ae1eb89d517a41eee3075f6a1b7ac169affef945743f41bf30e
4
+ data.tar.gz: d3b47ece081746d69226e5eef927516637a112a49d47407c5302e680becd87e3
5
+ SHA512:
6
+ metadata.gz: 93b242aafe6689f021f2d19ecd11538fe8dfb28ccc7dda93e597d473f4853270edcd9192bad2dfb30b7b7a1e283614e08bf4e7e8f3f903d20152f3f76e61e97f
7
+ data.tar.gz: cb588865edaece99a651dc2369e22983729c83588ab975c07cae80fbb4cef5457687f935a4716649b915f7dbac5083ca47adef962bb9cf0735a606aee3c20dca
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *~
2
+ /pkg/
3
+ /tmp/
4
+ /.bundle/
5
+ /Gemfile.lock
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ jruby-9.1.15.0
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+
2
+ MIT License
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Redis Custom Restock Noti input plugin for Embulk
2
+
3
+ TODO: Write short description here and embulk-input-redis_custom_restock_noti.gemspec file.
4
+
5
+ ## Overview
6
+
7
+ * **Plugin type**: input
8
+ * **Resume supported**: yes
9
+ * **Cleanup supported**: yes
10
+ * **Guess supported**: no
11
+
12
+ ## Configuration
13
+
14
+ - **option1**: description (integer, required)
15
+ - **option2**: description (string, default: `"myvalue"`)
16
+ - **option3**: description (string, default: `null`)
17
+
18
+ ## Example
19
+
20
+ ```yaml
21
+ in:
22
+ type: redis_custom_restock_noti
23
+ option1: example1
24
+ option2: example2
25
+ ```
26
+
27
+
28
+ ## Build
29
+
30
+ ```
31
+ $ rake
32
+ ```
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task default: :build
@@ -0,0 +1,21 @@
1
+
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "embulk-input-redis_custom_restock_noti"
4
+ spec.version = "0.1.0"
5
+ spec.authors = ["iktae_lee"]
6
+ spec.summary = "Redis Custom Restock Noti input plugin for Embulk"
7
+ spec.description = "Loads records from Redis Custom Restock Noti."
8
+ spec.email = ["iktae_lee@kolon.com"]
9
+ spec.licenses = ["MIT"]
10
+ spec.homepage = "https://gitlab.kolonfnc.com/iktae_lee/embulk-input-redis_custom_restock_noti.git"
11
+
12
+ spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
13
+ spec.test_files = spec.files.grep(%r{^(test|spec)/})
14
+ spec.require_paths = ["lib"]
15
+
16
+ #spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
17
+ spec.add_dependency 'redis', ['>= 3.0.5']
18
+ spec.add_development_dependency 'embulk', ['>= 0.9.23']
19
+ spec.add_development_dependency 'bundler', ['>= 1.10.6']
20
+ spec.add_development_dependency 'rake', ['>= 10.0']
21
+ end
@@ -0,0 +1,88 @@
1
+ module Embulk
2
+ module Input
3
+
4
+ class RedisCustomRestockNoti < InputPlugin
5
+ require 'redis'
6
+
7
+ Plugin.register_input("redis_custom_restock_noti", self)
8
+
9
+ def self.transaction(config, &control)
10
+ task = {
11
+ 'host' => config.param('host', :string, :default => 'localhost'),
12
+ 'port' => config.param('port', :integer, :default => 6379),
13
+ 'db' => config.param('db', :integer, :default => 0),
14
+ 'keys_pattern' => config.param('keys_pattern', :string, :default => ''),
15
+ 'columns' =>
16
+ config.param('columns', :array, :default => []).inject({}){|a, col|
17
+ a[col['name']] = col['type'].to_sym
18
+ a
19
+ },
20
+ 'rows' => 0
21
+ }
22
+
23
+ columns = task['columns'].map.with_index{|(name, type), i|
24
+ Column.new(i, name, type)
25
+ }
26
+
27
+ puts "Redis input started."
28
+ commit_reports = yield(task, columns, 1)
29
+ puts "Redis input finished. Commit reports = #{commit_reports.to_json}"
30
+
31
+ return {}
32
+ end
33
+
34
+ # def self.resume(task, columns, count, &control)
35
+ # task_reports = yield(task, columns, count)
36
+
37
+ # next_config_diff = {}
38
+ # return next_config_diff
39
+ # end
40
+
41
+ # TODO
42
+ # def self.guess(config)
43
+ # sample_records = [
44
+ # {"example"=>"a", "column"=>1, "value"=>0.1},
45
+ # {"example"=>"a", "column"=>2, "value"=>0.2},
46
+ # ]
47
+ # columns = Guess::SchemaGuess.from_hash_records(sample_records)
48
+ # return {"columns" => columns}
49
+ # end
50
+
51
+ # def init
52
+ # # initialization code:
53
+ # @option1 = task["option1"]
54
+ # @option2 = task["option2"]
55
+ # @option3 = task["option3"]
56
+ # end
57
+
58
+ def run
59
+ puts "Redis input thread #{@index}..."
60
+ r = Redis.new(:host => @task['host'], :port => @task['port'], :db => @task['db'])
61
+ r.keys("#{@task['keys_pattern']}").each do |key|
62
+
63
+ k = key.split(':')
64
+ v = r.zrange(key, 0, -1, :with_scores => true)
65
+
66
+ v.each do |e|
67
+ temp = Array.new
68
+ temp.push(k[1]) # siteUid
69
+ temp.push(k[3].split('-')[0]) # productCode
70
+ temp.push(k[3].split('-')[1]) # size
71
+ temp.push(e[0]) # customerUid
72
+ temp.push(Time.at(e[1] / 1000)) # score(timestamp)
73
+ @page_builder.add(temp)
74
+ end
75
+
76
+ @task['rows'] += 1
77
+ end
78
+ @page_builder.finish # don't forget to call finish :-)
79
+
80
+ commit_report = {
81
+ "rows" => @task['rows']
82
+ }
83
+ return commit_report
84
+ end
85
+ end
86
+
87
+ end
88
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: embulk-input-redis_custom_restock_noti
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - iktae_lee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-07-01 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: embulk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.23
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.23
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.10.6
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.10.6
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Loads records from Redis Custom Restock Noti.
70
+ email:
71
+ - iktae_lee@kolon.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".ruby-version"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - embulk-input-redis_custom_restock_noti.gemspec
83
+ - lib/embulk/input/redis_custom_restock_noti.rb
84
+ homepage: https://gitlab.kolonfnc.com/iktae_lee/embulk-input-redis_custom_restock_noti.git
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.0.3
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Redis Custom Restock Noti input plugin for Embulk
107
+ test_files: []