message-sqs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +28 -0
  3. data/lib/message-sqs.rb +28 -0
  4. metadata +75 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 26a403abf520262b0652793cb8b4304f7552780e
4
+ data.tar.gz: 66a6abe0d12b7057194a9ed7c96abe111a7be37f
5
+ SHA512:
6
+ metadata.gz: b8c2077dddec198879e902d060d3a13eb02a4e2fe97409699ac120eeae28d9fe05ad49d792d2b6bff907b849638efc7a116c6bfb476eb52cc23fe8b6b5470991
7
+ data.tar.gz: bb4f624d07cc1bb6d25df629b632bdb79ed1bef48964e190b5be8aaff31912af83afe3ec34b598d986430a5f65392b9b87c0d8c5470b124f01a3e349d641a08b
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Message-SQS
2
+
3
+ Message provides flexible & reliable background/asynchronous job processing mechanism on top of simple queue interface.
4
+
5
+ Message-SQS hooks up AWS SQS with Message background/asynchronous job processing mechanism.
6
+
7
+
8
+ ## Installation
9
+
10
+ gem 'message-sqs'
11
+
12
+ ## How to use
13
+
14
+ ### Queuing jobs
15
+
16
+ Inspired by delayed_job API, call .enq.method(params) on any object and it will be processed in the background.
17
+
18
+ # without message
19
+ @img.resize(36)
20
+
21
+ # with message
22
+ @img.enq.resize(36)
23
+
24
+ ### Start worker to process jobs
25
+
26
+ Message.worker.start
27
+
28
+ ## see https://github.com/xli/message for more details
@@ -0,0 +1,28 @@
1
+ require 'aws/sqs'
2
+ require 'message'
3
+
4
+ class MessageSqs
5
+ attr_reader :name
6
+ def initialize(name)
7
+ @name = name
8
+ @queue = AWS::SQS.new.queues.create(@name)
9
+ end
10
+
11
+ def enq(msg)
12
+ @queue.send_message(msg)
13
+ end
14
+ alias :<< :enq
15
+
16
+ def deq(size=1, &block)
17
+ @queue.receive_message(:limit => size) do |msg|
18
+ block.call(msg.body)
19
+ end
20
+ end
21
+
22
+ def size
23
+ @queue.approximate_number_of_messages
24
+ end
25
+ end
26
+
27
+ Message.queue.adapters[:sqs] = MessageSqs
28
+ Message.queue.adapter = :sqs
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: message-sqs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Xiao Li
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.43.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.43.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: message
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.1
41
+ description: |
42
+ Hook up AWS SQS with Message background/asynchronous job processing mechanism.
43
+ email:
44
+ - swing1979@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - README.md
50
+ - lib/message-sqs.rb
51
+ homepage: https://github.com/xli/message-sqs
52
+ licenses:
53
+ - MIT
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.2.0
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Message SQS queue adapter.
75
+ test_files: []