embulk-output-wendelin 0.1.1
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 +7 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +24 -0
- data/LICENSE.txt +14 -0
- data/README.md +39 -0
- data/Rakefile +3 -0
- data/embulk-output-wendelin.gemspec +20 -0
- data/lib/embulk/output/wendelin.rb +96 -0
- data/lib/embulk/output/wendelin_client.rb +105 -0
- data/vendor/cache/embulk-0.8.18.gem +0 -0
- data/vendor/cache/jruby-jars-9.1.5.0.gem +0 -0
- data/vendor/cache/rake-12.0.0.gem +0 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3945e56edb675247ac6b31f37d43b9f2c867ea8
|
4
|
+
data.tar.gz: 419b936e9107857563c010697be4c6625f15d270
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f7452537e2afe252d78df8c773aafb072a1217c676c763d4d7e1911c88061920cf90a50ca0aa204a1e23dd263533a79d9592df5f763cc5352326c8bd2eb487b
|
7
|
+
data.tar.gz: 17acfdfb768fb6a5d914cd708db697f990462dcc77eb6d22f06ea939fa57ebffc7e46104eac4eaf0b3f08abc89cbd88d64ac85e0a11593f3a4df95ee0a929e04
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
embulk-output-wendelin (0.1.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
embulk (0.8.18)
|
10
|
+
jruby-jars (= 9.1.5.0)
|
11
|
+
jruby-jars (9.1.5.0)
|
12
|
+
rake (12.0.0)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
bundler (>= 1.10.6)
|
19
|
+
embulk (>= 0.8.13)
|
20
|
+
embulk-output-wendelin!
|
21
|
+
rake (>= 10.0)
|
22
|
+
|
23
|
+
BUNDLED WITH
|
24
|
+
1.14.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright (C) 2016 Nexedi SA and Contributors
|
2
|
+
Klaus Wölfel <klaus@nexedi.com>
|
3
|
+
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
you may not use this file except in compliance with the License.
|
6
|
+
You may obtain a copy of the License at
|
7
|
+
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
See the License for the specific language governing permissions and
|
14
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Wendelin output plugin for Embulk
|
2
|
+
|
3
|
+
TODO: Write short description here and embulk-output-wendelin.gemspec file.
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
* **Plugin type**: output
|
8
|
+
* **Load all or nothing**: no
|
9
|
+
* **Resume supported**: no
|
10
|
+
* **Cleanup supported**: yes
|
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: file
|
23
|
+
path_prefix: /sample_
|
24
|
+
parser:
|
25
|
+
type: none
|
26
|
+
out:
|
27
|
+
type: wendelin
|
28
|
+
tag: app.tag1.txt
|
29
|
+
streamtool_uri: https://url_to_erp5_instance/erp5/portal_ingestion_policies/my_policy
|
30
|
+
user: my_username
|
31
|
+
password: may_password
|
32
|
+
```
|
33
|
+
|
34
|
+
|
35
|
+
## Build
|
36
|
+
|
37
|
+
```
|
38
|
+
$ rake
|
39
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
Gem::Specification.new do |spec|
|
3
|
+
spec.name = "embulk-output-wendelin"
|
4
|
+
spec.version = "0.1.1"
|
5
|
+
spec.authors = ["Klaus Woelfel"]
|
6
|
+
spec.summary = "Wendelin output plugin for Embulk"
|
7
|
+
spec.description = "Dumps records to Wendelin."
|
8
|
+
spec.email = ["YOUR_NAME"]
|
9
|
+
spec.licenses = ["MIT"]
|
10
|
+
# TODO set this: spec.homepage = "https://github.com/YOUR_NAME/embulk-output-wendelin"
|
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_development_dependency 'embulk', ['>= 0.8.13']
|
18
|
+
spec.add_development_dependency 'bundler', ['>= 1.10.6']
|
19
|
+
spec.add_development_dependency 'rake', ['>= 10.0']
|
20
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require_relative 'wendelin_client'
|
3
|
+
|
4
|
+
module Embulk
|
5
|
+
module Output
|
6
|
+
|
7
|
+
class Wendelin < OutputPlugin
|
8
|
+
Plugin.register_output("wendelin", self)
|
9
|
+
|
10
|
+
def self.transaction(config, schema, count, &control)
|
11
|
+
# configuration code:
|
12
|
+
task = {
|
13
|
+
"tag" => config.param("tag", :string, default: nil),
|
14
|
+
# where Wendelin's Input Stream Tool is located,
|
15
|
+
# ex http://example.com/erp5/portal_ingestion_policies/example_ingestion
|
16
|
+
"streamtool_uri" => config.param("streamtool_uri", :string),
|
17
|
+
|
18
|
+
# credentials to authenticate this fluentd to wendelin
|
19
|
+
# by default credentials are not used
|
20
|
+
# TODO user/password -> certificate
|
21
|
+
"user" => config.param("user", :string, defualt: nil),
|
22
|
+
"password" => config.param("password", :string, default: nil),
|
23
|
+
|
24
|
+
"path_prefix" => config.param("path_prefix", :string, :default => nil),
|
25
|
+
}
|
26
|
+
|
27
|
+
# resumable output:
|
28
|
+
# resume(task, schema, count, &control)
|
29
|
+
|
30
|
+
#Embulk.logger.info { config.to_s }
|
31
|
+
#Embulk.logger.info { schema.to_s }
|
32
|
+
#Embulk.logger.info { count.to_s }
|
33
|
+
|
34
|
+
|
35
|
+
# non-resumable output:
|
36
|
+
task_reports = yield(task)
|
37
|
+
next_config_diff = {}
|
38
|
+
return next_config_diff
|
39
|
+
end
|
40
|
+
|
41
|
+
#def self.resume(task, schema, count, &control)
|
42
|
+
# task_reports = yield(task)
|
43
|
+
#
|
44
|
+
# next_config_diff = {}
|
45
|
+
# return next_config_diff
|
46
|
+
#end
|
47
|
+
|
48
|
+
def init
|
49
|
+
# initialization code:
|
50
|
+
credentials = {}
|
51
|
+
#Embulk.logger.info { "Test" }
|
52
|
+
#Embulk.logger.info { schema.to_s }
|
53
|
+
#Embulk.logger.info "Test"
|
54
|
+
@tag = task["tag"]
|
55
|
+
streamtool_uri = task["streamtool_uri"]
|
56
|
+
unless task["user"].nil?
|
57
|
+
credentials["user"] = task["user"]
|
58
|
+
credentials["password"] = task["password"]
|
59
|
+
end
|
60
|
+
@wendelin = WendelinClient.new(streamtool_uri, credentials, Embulk.logger)
|
61
|
+
end
|
62
|
+
|
63
|
+
def close
|
64
|
+
end
|
65
|
+
|
66
|
+
def add(page)
|
67
|
+
# output code:
|
68
|
+
#page.each do |record|
|
69
|
+
#hash = Hash[schema.names.zip(record)]
|
70
|
+
#end
|
71
|
+
#Embulk.logger.info { page.to_s }
|
72
|
+
page.each do |record|
|
73
|
+
#Embulk.logger.info { record.to_s }
|
74
|
+
tag = record[1].gsub(File::ALT_SEPARATOR || File::SEPARATOR, '.')[1..-1]
|
75
|
+
unless @tag.nil?
|
76
|
+
tag = @tag + "." + tag
|
77
|
+
end
|
78
|
+
Embulk.logger.info{ tag }
|
79
|
+
@wendelin.ingest(tag, Base64.decode64(record[0]))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def finish
|
84
|
+
end
|
85
|
+
|
86
|
+
def abort
|
87
|
+
end
|
88
|
+
|
89
|
+
def commit
|
90
|
+
task_report = {}
|
91
|
+
return task_report
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# module to ingest data to a Wendelin through HTTP endpoint
|
2
|
+
# Copyright (C) 2015 Nexedi SA and Contributors.
|
3
|
+
# Kirill Smelkov <kirr@nexedi.com>
|
4
|
+
#
|
5
|
+
# This program is free software: you can Use, Study, Modify and Redistribute
|
6
|
+
# it under the terms of the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
|
19
|
+
require 'net/http'
|
20
|
+
require 'openssl'
|
21
|
+
|
22
|
+
|
23
|
+
# class representing a Wendelin client
|
24
|
+
class WendelinClient
|
25
|
+
|
26
|
+
# `streamtool_uri` - URI pointing to portal_input_data_stream "mountpoint"
|
27
|
+
# `credentials` # {'user' => _, 'password' => _} TODO change to certificate
|
28
|
+
# `log` - logger to use
|
29
|
+
def initialize(streamtool_uri, credentials, log)
|
30
|
+
@streamtool_uri = streamtool_uri
|
31
|
+
@credentials = credentials
|
32
|
+
@log = log
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# ingest `data_chunk` to a stream referenced as `reference`
|
37
|
+
def ingest(reference, data_chunk)
|
38
|
+
uri = URI("#{@streamtool_uri}/ingest?reference=#{reference}")
|
39
|
+
req = Net::HTTP::Post.new(uri)
|
40
|
+
if @credentials.has_key?('user')
|
41
|
+
req.basic_auth @credentials['user'], @credentials['password']
|
42
|
+
end
|
43
|
+
|
44
|
+
# TODO ensure content-type is 'raw', e.g. this way
|
45
|
+
# (but then querystring ?reference=... is lost)
|
46
|
+
# req.body = data_chunk
|
47
|
+
# req.content_type = 'application/octet-stream'
|
48
|
+
req.set_form_data('data_chunk' => data_chunk)
|
49
|
+
|
50
|
+
#@log.on_trace do
|
51
|
+
# @log.trace '>>> REQUEST'
|
52
|
+
# @log.trace "method\t=> #{req.method}"
|
53
|
+
# @log.trace "path\t=> #{req.path}"
|
54
|
+
# @log.trace "uri\t=> #{req.uri}"
|
55
|
+
# @log.trace "body\t=> #{req.body}"
|
56
|
+
# @log.trace "body_stream\t=> #{req.body_stream}"
|
57
|
+
# req.each {|h| @log.trace "#{h}:\t#{req[h]}"}
|
58
|
+
# @log.trace
|
59
|
+
#end
|
60
|
+
|
61
|
+
begin
|
62
|
+
# TODO keep connection open (so that every new ingest does not do
|
63
|
+
# full connect again)
|
64
|
+
res = Net::HTTP.start(uri.hostname, uri.port,
|
65
|
+
:use_ssl => (uri.scheme == 'https'),
|
66
|
+
# NOTE = "do not check server cert"
|
67
|
+
# TODO move this out to conf parameters
|
68
|
+
:verify_mode => OpenSSL::SSL::VERIFY_NONE,
|
69
|
+
|
70
|
+
# Net::HTTP default open timeout is infinity, which results
|
71
|
+
# in thread hang forever if other side does not fully
|
72
|
+
# establish connection. Default read_timeout is 60 seconds.
|
73
|
+
# We go safe way and make sure all timeouts are defined.
|
74
|
+
:ssl_timeout => 60,
|
75
|
+
:open_timeout => 60,
|
76
|
+
:read_timeout => 60,
|
77
|
+
) do |http|
|
78
|
+
http.request(req)
|
79
|
+
end
|
80
|
+
|
81
|
+
rescue
|
82
|
+
# some http/ssl/other connection error
|
83
|
+
#@log.warn "HTTP ERROR:"
|
84
|
+
raise
|
85
|
+
|
86
|
+
else
|
87
|
+
#@log.on_trace do
|
88
|
+
# @log.trace '>>> RESPONSE'
|
89
|
+
# res.each {|h| @log.trace "#{h}:\t#{res[h]}"}
|
90
|
+
# @log.trace "code\t=> #{res.code}"
|
91
|
+
# @log.trace "msg\t=> #{res.message}"
|
92
|
+
# @log.trace "class\t=> #{res.class}"
|
93
|
+
# @log.trace "body:", res.body
|
94
|
+
#end
|
95
|
+
|
96
|
+
if res.kind_of?(Net::HTTPSuccess) # res.code is 2XX
|
97
|
+
#@log.info "ingested ok"
|
98
|
+
else
|
99
|
+
#@log.warn "FAIL:"
|
100
|
+
res.value
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-output-wendelin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Klaus Woelfel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: embulk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.13
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.13
|
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.10.6
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.10.6
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Dumps records to Wendelin.
|
56
|
+
email:
|
57
|
+
- YOUR_NAME
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- Gemfile.lock
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- embulk-output-wendelin.gemspec
|
68
|
+
- lib/embulk/output/wendelin.rb
|
69
|
+
- lib/embulk/output/wendelin_client.rb
|
70
|
+
- vendor/cache/embulk-0.8.18.gem
|
71
|
+
- vendor/cache/jruby-jars-9.1.5.0.gem
|
72
|
+
- vendor/cache/rake-12.0.0.gem
|
73
|
+
homepage:
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.5.1
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Wendelin output plugin for Embulk
|
97
|
+
test_files: []
|