aws_pipes 0.0.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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +57 -0
- data/Rakefile +1 -0
- data/aws_pipes.gemspec +22 -0
- data/bin/aws_queue +68 -0
- data/lib/aws_pipes/version.rb +3 -0
- data/lib/aws_pipes.rb +5 -0
- metadata +87 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Joe Nelson
|
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,57 @@
|
|
1
|
+
Send messages between Amazon EC2 instances through Unix pipes.
|
2
|
+
|
3
|
+
This gem is built on top of the Amazon [Simple Queue
|
4
|
+
Service](http://aws.amazon.com/sqs/) (SQS) which lets you
|
5
|
+
|
6
|
+
- Move data between distributed components of your application without
|
7
|
+
losing messages or requiring each component to be always available.
|
8
|
+
- Get started with no extra installed software or special firewall
|
9
|
+
configurations.
|
10
|
+
- Connect machines on different networks, developed with different
|
11
|
+
technologies, and running at different times.
|
12
|
+
- Save messages in the queue for up to 14 days.
|
13
|
+
|
14
|
+
Text is the universal interface, and any application that can read and
|
15
|
+
write text can use this gem – no knowledge of the Amazon API is
|
16
|
+
required.
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
# write data to an SQS queue named "foo"
|
21
|
+
your_program | aws_queue write foo
|
22
|
+
|
23
|
+
# read data from an SQS queue named "foo"
|
24
|
+
aws_queue read foo | your_program
|
25
|
+
|
26
|
+
To use this program you will need to [create a
|
27
|
+
queue](https://console.aws.amazon.com/sqs/) in the Amazon Web Console.
|
28
|
+
|
29
|
+
## Installation
|
30
|
+
|
31
|
+
1. Sign up for an [AWS account](http://aws.amazon.com/).
|
32
|
+
1. Find your secret key and key id in *My Account* > *Security Credentials*.
|
33
|
+
1. (optionally) Set your environment variables AWS_ACCESS_KEY_ID, and
|
34
|
+
AWS_ACCESS_KEY accordingly.
|
35
|
+
1. Run `gem install aws_pipes` from the command line.
|
36
|
+
|
37
|
+
This will install the `aws_queue` command to your path. If you haven't
|
38
|
+
stored your Amazon credentials in environment variables, you can pass
|
39
|
+
them in as command line options. For more info, run
|
40
|
+
|
41
|
+
aws_queue --help
|
42
|
+
|
43
|
+
## Examples
|
44
|
+
|
45
|
+
### Downloading a massive list of urls in parallel.
|
46
|
+
|
47
|
+
One computer can feed a list of urls to workers which download them.
|
48
|
+
Suppose the urls are stored in `urls.txt`. Just redirect the file into a
|
49
|
+
queue:
|
50
|
+
|
51
|
+
aws_queue write to_be_downloaded < urls.txt
|
52
|
+
|
53
|
+
Then have each worker pull from the `to_be_downloaded` queue and
|
54
|
+
repeatedly run a command to download each url. The queue supports many
|
55
|
+
simultaneous readers and prevents duplicate work.
|
56
|
+
|
57
|
+
aws_queue read to_be_downloaded | xargs -L1 wget
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/aws_pipes.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'aws_pipes/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "aws_pipes"
|
8
|
+
gem.version = AwsPipes::VERSION
|
9
|
+
gem.authors = ["Joe Nelson"]
|
10
|
+
gem.email = ["cred+github@begriffs.com"]
|
11
|
+
gem.description = %q{Send messages between Amazon EC2 instances through Unix pipes.}
|
12
|
+
gem.summary = %q{AWS queues à la Unix}
|
13
|
+
gem.homepage = "https://github.com/begriffs/aws_pipes"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "aws-sdk"
|
21
|
+
gem.add_dependency "trollop"
|
22
|
+
end
|
data/bin/aws_queue
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'trollop'
|
4
|
+
require 'aws-sdk'
|
5
|
+
require_relative '../lib/aws_pipes/version'
|
6
|
+
|
7
|
+
## USAGE ###########################################################################
|
8
|
+
|
9
|
+
opts = Trollop::options do
|
10
|
+
version "aws_queue #{AwsPipes::VERSION} (c) 2013 Joe Nelson"
|
11
|
+
banner <<-EOS
|
12
|
+
Read and write Amazon SQS through unix pipes.
|
13
|
+
|
14
|
+
You may provide Amazon authentication through these environment variables:
|
15
|
+
AWS_ACCESS_KEY_ID - AWS access key id
|
16
|
+
AWS_ACCESS_KEY - AWS secret access key
|
17
|
+
|
18
|
+
Usage:
|
19
|
+
aws_queue [options] write <queue-name>
|
20
|
+
Send STDIN to an Amazon SQS queue, one message per line.
|
21
|
+
|
22
|
+
aws_queue [options] read <queue-name>
|
23
|
+
Print messages from Amazon SQS queue to STDOUT, one message per line.
|
24
|
+
|
25
|
+
where [options] are:
|
26
|
+
EOS
|
27
|
+
|
28
|
+
opt :keyid, "AWS access key id", :type => :string
|
29
|
+
opt :key, "AWS secret access key", :type => :string
|
30
|
+
end
|
31
|
+
|
32
|
+
## SETUP ###########################################################################
|
33
|
+
|
34
|
+
access_key_id = ENV['AWS_ACCESS_KEY_ID'] || opts[:keyid] || Trollop::die("Missing access key id")
|
35
|
+
secret_access_key = ENV['AWS_ACCESS_KEY'] || opts[:key] || Trollop::die("Missing secret access key")
|
36
|
+
sqs = AWS::SQS.new(
|
37
|
+
:access_key_id => access_key_id,
|
38
|
+
:secret_access_key => secret_access_key
|
39
|
+
)
|
40
|
+
|
41
|
+
operation = ARGV.shift
|
42
|
+
unless %w(read write).include? operation
|
43
|
+
Trollop::die "Unknown operation \"#{operation}\" -- expecting \"read\" or \"write\""
|
44
|
+
end
|
45
|
+
|
46
|
+
q_name = ARGV.shift
|
47
|
+
Trollop::die "Missing queue name" unless q_name
|
48
|
+
|
49
|
+
## OPERATION #######################################################################
|
50
|
+
|
51
|
+
begin
|
52
|
+
q = sqs.queues.named q_name
|
53
|
+
case operation
|
54
|
+
when 'read'
|
55
|
+
$stdout.sync = true
|
56
|
+
q.poll do |msg|
|
57
|
+
puts msg.body
|
58
|
+
end
|
59
|
+
when 'write'
|
60
|
+
$stdin.sync = true
|
61
|
+
while msg = gets
|
62
|
+
q.send_message msg
|
63
|
+
end
|
64
|
+
end
|
65
|
+
rescue AWS::SQS::Errors::NonExistentQueue => e
|
66
|
+
warn e
|
67
|
+
exit 1
|
68
|
+
end
|
data/lib/aws_pipes.rb
ADDED
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aws_pipes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Joe Nelson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: aws-sdk
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: trollop
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Send messages between Amazon EC2 instances through Unix pipes.
|
47
|
+
email:
|
48
|
+
- cred+github@begriffs.com
|
49
|
+
executables:
|
50
|
+
- aws_queue
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- aws_pipes.gemspec
|
60
|
+
- bin/aws_queue
|
61
|
+
- lib/aws_pipes.rb
|
62
|
+
- lib/aws_pipes/version.rb
|
63
|
+
homepage: https://github.com/begriffs/aws_pipes
|
64
|
+
licenses: []
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.8.24
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: AWS queues à la Unix
|
87
|
+
test_files: []
|