akane-kinesis 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +2 -0
- data/akane-kinesis.gemspec +26 -0
- data/lib/akane/kinesis.rb +2 -0
- data/lib/akane/kinesis/version.rb +5 -0
- data/lib/akane/storages/kinesis.rb +78 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 047ec6dfebdbc66322a72172726212c5f7beb39a
|
4
|
+
data.tar.gz: a8ca2343ad344cd7e76c5af3dd8fe0800027fd97
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b5cf586291fc3854b96b7afbba43f4ca3c2160643b467fffeb561cc87acb184eab46aa7bc4e5d60c5bfd6e39659ef6a411113ae00f01abaad2826e4cadde282e
|
7
|
+
data.tar.gz: d192e3cbbdba807515ff43b111e8f4736ef85dfed6124477780316923c12d3e72ef4ab1037586db653ec01907eb45302f7a8f542d65191e923617f515fe4ced2
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Yoshiori SHOJI
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Akane::Kinesis
|
2
|
+
storage plugin for [akane](https://github.com/sorah/akane/) that post to Amazon Kinesis.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
gem 'akane-kinesis'
|
9
|
+
|
10
|
+
And then execute:
|
11
|
+
|
12
|
+
$ bundle
|
13
|
+
|
14
|
+
Or install it yourself as:
|
15
|
+
|
16
|
+
$ gem install akane-kinesis
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
`akane.yml`
|
21
|
+
|
22
|
+
```yml
|
23
|
+
storages:
|
24
|
+
- kinesis:
|
25
|
+
aws_access_key_id: xxx
|
26
|
+
aws_secret_access_key: xxxx
|
27
|
+
region: ap-northeast-1
|
28
|
+
kinesis_stream_name: twitter
|
29
|
+
```
|
30
|
+
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it ( https://github.com/yoshiori/akane-kinesis/fork )
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'akane/kinesis/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "akane-kinesis"
|
8
|
+
spec.version = Akane::Kinesis::VERSION
|
9
|
+
spec.authors = ["Yoshiori SHOJI"]
|
10
|
+
spec.email = ["yoshiori@gmail.com"]
|
11
|
+
spec.summary = %q{storage plugin for akane that post to Amazon Kinesis.}
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "https://github.com/yoshiori/akane-kinesis"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "akane"
|
25
|
+
spec.add_dependency "aws-sdk"
|
26
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'akane/storages/abstract_storage'
|
2
|
+
require 'aws-sdk'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Akane
|
6
|
+
module Storages
|
7
|
+
class Kinesis < AbstractStorage
|
8
|
+
|
9
|
+
DEFAULT_REGION = "us-east-1"
|
10
|
+
|
11
|
+
def initialize(config: raise(ArgumentError, 'missing config'), logger: Logger.new($stdout))
|
12
|
+
super
|
13
|
+
|
14
|
+
@access_key_id = @config['aws_access_key_id'] || ENV['AWS_ACCESS_KEY_ID']
|
15
|
+
@secret_access_key = @config['aws_secret_access_key'] || ENV['AWS_SECRET_ACCESS_KEY']
|
16
|
+
@region = @config['region'] || DEFAULT_REGION
|
17
|
+
@stream_name = @config['kinesis_stream_name']
|
18
|
+
|
19
|
+
unless @access_key_id
|
20
|
+
raise ArgumentError, "config `aws_access_key_id` is required"
|
21
|
+
end
|
22
|
+
unless @secret_access_key
|
23
|
+
raise ArgumentError, "config `aws_secret_access_key` is required"
|
24
|
+
end
|
25
|
+
unless @stream_name
|
26
|
+
raise ArgumentError, "config `kinesis_stream_name` is required"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def record_tweet(account, tweet)
|
32
|
+
|
33
|
+
kinesis.put_record(
|
34
|
+
stream_name: @stream_name,
|
35
|
+
data: tweet.attrs.merge(account: account).to_json,
|
36
|
+
partition_key: "tweet"
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
def mark_as_deleted(account, user_id, tweet_id)
|
41
|
+
data = {
|
42
|
+
account: account,
|
43
|
+
user_id: user_id,
|
44
|
+
tweet_id: tweet_id,
|
45
|
+
}
|
46
|
+
kinesis.put_record(
|
47
|
+
stream_name: @stream_name,
|
48
|
+
data: data.to_json,
|
49
|
+
partition_key: "deletion"
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def record_event(account, event)
|
54
|
+
kinesis.put_record(
|
55
|
+
stream_name: @stream_name,
|
56
|
+
data: event.attrs.merge(account: account).to_json,
|
57
|
+
partition_key: "event"
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
def record_message(account, message)
|
62
|
+
kinesis.put_record(
|
63
|
+
stream_name: @stream_name,
|
64
|
+
data: message.attrs.merge(account: account).to_json,
|
65
|
+
partition_key: "dm"
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
def kinesis
|
70
|
+
@kinesis ||= AWS::Kinesis.new(
|
71
|
+
access_key_id: @access_key_id,
|
72
|
+
secret_access_key: @secret_access_key,
|
73
|
+
region: @region,
|
74
|
+
).client
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: akane-kinesis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yoshiori SHOJI
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: akane
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aws-sdk
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: storage plugin for akane that post to Amazon Kinesis.
|
70
|
+
email:
|
71
|
+
- yoshiori@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- akane-kinesis.gemspec
|
82
|
+
- lib/akane/kinesis.rb
|
83
|
+
- lib/akane/kinesis/version.rb
|
84
|
+
- lib/akane/storages/kinesis.rb
|
85
|
+
homepage: https://github.com/yoshiori/akane-kinesis
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.2.2
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: storage plugin for akane that post to Amazon Kinesis.
|
109
|
+
test_files: []
|