cloud_flow 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cloud_flow.rb +14 -4
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 264e0c36847fc01a6400b66829640d88103ac747
4
- data.tar.gz: e34820c6e782cf015d013581ff2aba5f878ff33a
3
+ metadata.gz: ed7c28504ce14f5ee96bfbdc7d18e50a1d11316f
4
+ data.tar.gz: 57d9ed689c4a46f73c7bbb4a1761ff7f5a374615
5
5
  SHA512:
6
- metadata.gz: 2686a2958245ba902353348516253e439c0499830fe5ba600fe924c2ee76c2d8c90a69404bd15c5ee409e6e7c54b07ed0da845c271369c4adb2aaaaf8faf84dd
7
- data.tar.gz: ce732b8bee3cd29cc96795b97a466511e6a32ebcf26ba498f947e85873b59df19ef1ab103cb23bf0793d90307888de3aca38c9c55d0e305fc2589002185d6117
6
+ metadata.gz: e68c05ea2464ba9cf1ca81acbd29a8dac2b1b11f2ee834bfd0924a0359db376e57e7cd69dc43645380ed6b10605b5c26d62cce14e24e4d7091be4edee525a9f1
7
+ data.tar.gz: 6e8aa8e71e47b111741ea8ef6d4769df013bfbcad0bdcde529d7fc2faf7bab4ca1a38fcd9d43d11ccdf9de7c36efadf40dc3ef1114a23db7775e5448c027f588
data/lib/cloud_flow.rb CHANGED
@@ -5,11 +5,11 @@ class CloudFlow
5
5
  def initialize(name)
6
6
  @namespace = name
7
7
  sqs = AWS::SQS.new
8
- @queue = sqs.queues.named("cloudflow_#{@namespace}")
8
+ @queue = create_or_find_queue(sqs, "cloudflow_#{@namespace}")
9
9
  end
10
10
 
11
- # regist func correspond to given func name.
12
- # please avoid 'on', 'poll' since they are used already by CloudFlow.
11
+ # Create function correspond to given name.
12
+ # Please avoid 'on', 'poll' since they are used already by CloudFlow.
13
13
  # flow.on(:somefunc, &blk) generates flow#somefunc which is used to call the work.
14
14
  # @param name [String] the work's name.
15
15
  # @param block [Block] the work.
@@ -18,7 +18,7 @@ class CloudFlow
18
18
  define_receiving_method(name, &block)
19
19
  end
20
20
 
21
- # starts its work.
21
+ # Starts its work.
22
22
  def start
23
23
  @queue.poll do |msg|
24
24
  perform_message(msg)
@@ -27,6 +27,16 @@ class CloudFlow
27
27
 
28
28
  private
29
29
 
30
+ # creates of finds SQS queue by given name
31
+ # @param sqs [AWS::SQS]
32
+ # @param name [String]
33
+ # @return [AWS::SQS::Queue]
34
+ def create_or_find_queue(sqs, name)
35
+ sqs.queues.named(name)
36
+ rescue AWS::SQS::Errors::NonExistentQueue
37
+ sqs.queues.create(name)
38
+ end
39
+
30
40
  # defines method which does send message to SQS
31
41
  def define_sending_method(name)
32
42
  self.class.send(:define_method, name) do |*args|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kai Inui
@@ -10,7 +10,7 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-06-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Write multi-instance workflow easily
13
+ description: SQS Powered Multi-instance coding made easy
14
14
  email: me@kaiinui.com
15
15
  executables: []
16
16
  extensions: []
@@ -38,8 +38,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  version: '0'
39
39
  requirements: []
40
40
  rubyforge_project:
41
- rubygems_version: 2.2.2
41
+ rubygems_version: 2.3.0
42
42
  signing_key:
43
43
  specification_version: 4
44
44
  summary: SQS Powered Multi-instance coding made easy
45
45
  test_files: []
46
+ has_rdoc: