simple_qs 0.1.2 → 0.2

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,17 @@
1
+ ## 0.2
2
+
3
+ Features:
4
+
5
+ - Add new SQS endpoints
6
+ - Add new support for MaximumMessageSize, MessageRetentionPeriod attributes for queue
7
+
1
8
  ## 0.1.2
2
9
 
3
10
  Features:
11
+
4
12
  - Add exists? class method to SimpleQS::Queue
5
13
  - Add delete class method to SimpleQS::Queue
6
14
 
7
15
  Bugfixes:
16
+
8
17
  - Fix gemspec, gem now works as it should :)
data/README.md CHANGED
@@ -15,13 +15,14 @@
15
15
 
16
16
  You can select region for queue:
17
17
 
18
- # :default => 'queue.amazonaws.com'
19
- # :us_west_1 => 'us-west-1.queue.amazonaws.com'
20
- # :eu_west_1 => 'eu-west-1.queue.amazonaws.com'
21
- SimpleQS.host # => 'queue.amazonaws.com'
18
+ # :us_east_1 => 'sqs.us-east-1.amazonaws.com',
19
+ # :us_west_1 => 'sqs.us-west-1.amazonaws.com',
20
+ # :eu_west_1 => 'sqs.eu-west-1.amazonaws.com',
21
+ # :ap_southeast_1 => 'sqs.ap-southeast-1.amazonaws.com'
22
+ SimpleQS.host # => 'sqs.us-east-1.amazonaws.com'
22
23
 
23
24
  SimpleQS.host = :eu_west_1
24
- SimpleQS.host # => 'eu-west-1.queue.amazonaws.com'
25
+ SimpleQS.host # => 'sqs.eu-west-1.amazonaws.com'
25
26
 
26
27
  ### Queues ###
27
28
 
@@ -47,10 +48,22 @@ List all account's queues starting with 'test':
47
48
 
48
49
  SimpleQS::Queue.list('test')
49
50
 
51
+ Check if queue exists:
52
+
53
+ SimpleQS::Queue.exists?('queue_name')
54
+
50
55
  Change default visibility timeout for queue:
51
56
 
52
57
  SimpleQS::Queue.new('queue_name').set_visibility_timeout(120)
53
58
 
59
+ Change maximum message size for queue:
60
+
61
+ SimpleQS::Queue.new('queue_name').set_maximum_message_size(65536)
62
+
63
+ Change message retention period:
64
+
65
+ SimpleQS::Queue.new('queue_name').set_message_retention_period(1209600)
66
+
54
67
  Set queue attributes:
55
68
 
56
69
  SimpleQS::Queue.new('queue_name').set_attributes({:VisibilityTimeout => 120, :Policy => "policy JSON here"})
@@ -74,6 +87,10 @@ Delete queue:
74
87
 
75
88
  SimpleQS::Queue.new('queue_name').delete
76
89
 
90
+ Or:
91
+
92
+ SimpleQS::Queue.delete('queue_name')
93
+
77
94
  ### Messages ###
78
95
 
79
96
  Send message:
@@ -141,13 +158,14 @@ Marjan Krekoten' (krekoten@gmail.com)
141
158
 
142
159
  Можна обрати регіон, в якому буде створена черга:
143
160
 
144
- # :default => 'queue.amazonaws.com'
145
- # :us_west_1 => 'us-west-1.queue.amazonaws.com'
146
- # :eu_west_1 => 'eu-west-1.queue.amazonaws.com'
147
- SimpleQS.host # => 'queue.amazonaws.com'
161
+ # :us_east_1 => 'sqs.us-east-1.amazonaws.com',
162
+ # :us_west_1 => 'sqs.us-west-1.amazonaws.com',
163
+ # :eu_west_1 => 'sqs.eu-west-1.amazonaws.com',
164
+ # :ap_southeast_1 => 'sqs.ap-southeast-1.amazonaws.com'
165
+ SimpleQS.host # => 'sqs.us-east-1.amazonaws.com'
148
166
 
149
167
  SimpleQS.host = :eu_west_1
150
- SimpleQS.host # => 'eu-west-1.queue.amazonaws.com'
168
+ SimpleQS.host # => 'sqs.eu-west-1.amazonaws.com'
151
169
 
152
170
  ### Черги ###
153
171
 
@@ -173,10 +191,22 @@ Marjan Krekoten' (krekoten@gmail.com)
173
191
 
174
192
  SimpleQS::Queue.list('test')
175
193
 
194
+ Перевірити чи черга існує:
195
+
196
+ SimpleQS::Queue.exists?('queue_name')
197
+
176
198
  Змінити типовий час невидимості для даної черги:
177
199
 
178
200
  SimpleQS::Queue.new('queue_name').set_visibility_timeout(120)
179
201
 
202
+ Змінити максимальний розмір повідомлення:
203
+
204
+ SimpleQS::Queue.new('queue_name').set_maximum_message_size(65536)
205
+
206
+ Змінити період зберігання повідомлень для черги:
207
+
208
+ SimpleQS::Queue.new('queue_name').set_message_retention_period(1209600)
209
+
180
210
  Встановити атрибути черги:
181
211
 
182
212
  SimpleQS::Queue.new('queue_name').set_attributes({:VisibilityTimeout => 120, :Policy => "policy JSON here"})
@@ -200,6 +230,10 @@ Marjan Krekoten' (krekoten@gmail.com)
200
230
 
201
231
  SimpleQS::Queue.new('queue_name').delete
202
232
 
233
+ Або:
234
+
235
+ SimpleQS::Queue.delete('queue_name')
236
+
203
237
  ### Повідомлення ###
204
238
 
205
239
  Відправити повідомлення:
data/TODO.md CHANGED
@@ -1,3 +1,3 @@
1
1
  * Add interface for policy
2
2
  * RDoc
3
- * Handle big messages ( > 8 Kb) via S3 (send special message marker with bucket and object name where real message stored)
3
+ * Handle big messages ( > 64 Kb) via S3. (Is there any reason for this?)
@@ -7,9 +7,10 @@ module SimpleQS
7
7
  API_VERSION = '2009-02-01'
8
8
 
9
9
  SQS_HOSTS = {
10
- :default => 'queue.amazonaws.com',
11
- :us_west_1 => 'us-west-1.queue.amazonaws.com',
12
- :eu_west_1 => 'eu-west-1.queue.amazonaws.com'
10
+ :us_east_1 => 'sqs.us-east-1.amazonaws.com',
11
+ :us_west_1 => 'sqs.us-west-1.amazonaws.com',
12
+ :eu_west_1 => 'sqs.eu-west-1.amazonaws.com',
13
+ :ap_southeast_1 => 'sqs.ap-southeast-1.amazonaws.com'
13
14
  }
14
15
 
15
16
  autoload :Message, 'simple_qs/message'
@@ -26,12 +27,12 @@ module SimpleQS
26
27
  attr_reader :account_id
27
28
 
28
29
  def host=(value)
29
- raise ArgumentError, 'Expected value to be one of: :default, :us_west_1, :eu_west_1' unless SQS_HOSTS.key?(value)
30
+ raise ArgumentError, 'Expected value to be one of: :us_east_1, :us_west_1, :eu_west_1, :ap_southeast_1' unless SQS_HOSTS.key?(value)
30
31
  @host = value
31
32
  end
32
33
 
33
34
  def host
34
- @host ||= :default
35
+ @host ||= :us_east_1
35
36
  SQS_HOSTS[@host]
36
37
  end
37
38
  end
@@ -2,6 +2,8 @@ module SimpleQS
2
2
  class Queue
3
3
 
4
4
  class MaxVisibilityError < StandardError; end
5
+ class MaxMessageSizeError < StandardError; end
6
+ class MessageRetentionPeriodError < StandardError; end
5
7
 
6
8
  MAX_VISIBILITY_TIMEOUT = 43200
7
9
 
@@ -103,10 +105,33 @@ module SimpleQS
103
105
  def set_policy(policy)
104
106
  set_attributes({:Policy => policy})
105
107
  end
108
+
109
+ def set_maximum_message_size(message_size)
110
+ set_attributes({:MaximumMessageSize => message_size})
111
+ end
112
+
113
+ def set_message_retention_period(period)
114
+ set_attributes({:MessageRetentionPeriod => period})
115
+ end
116
+
117
+ ALLOWED_ATTRIBUTES = [
118
+ :VisibilityTimeout,
119
+ :Policy,
120
+ :MaximumMessageSize,
121
+ :MessageRetentionPeriod
122
+ ]
106
123
 
107
124
  def set_attributes(attributes)
108
- raise ArgumentError, "Allowed attributes: :VisibilityTimeout, :Policy" unless (attributes.keys - [:VisibilityTimeout, :Policy]).empty?
125
+ unless (attributes.keys - ALLOWED_ATTRIBUTES).empty?
126
+ raise ArgumentError, "Allowed attributes: #{ALLOWED_ATTRIBUTES.map {|attr| ":" << attr.to_s}.join(", ")}"
127
+ end
109
128
  self.class.check_visibility_timeout(attributes[:VisibilityTimeout]) if attributes[:VisibilityTimeout]
129
+ if attributes[:MaximumMessageSize] && !(1024..65536).include?(attributes[:MaximumMessageSize])
130
+ raise MaxMessageSizeError, 'MaximumMessageSize should be between 1024 and 65536'
131
+ end
132
+ if attributes[:MessageRetentionPeriod] && !(3600..1209600).include?(attributes[:MessageRetentionPeriod])
133
+ raise MessageRetentionPeriodError, 'MessageRetentionPeriod should be between 3600 and 1209600'
134
+ end
110
135
 
111
136
  params = {
112
137
  'Action' => 'SetQueueAttributes'
@@ -1,3 +1,3 @@
1
1
  module SimpleQS
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2'
3
3
  end
metadata CHANGED
@@ -4,9 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
7
  - 2
9
- version: 0.1.2
8
+ version: "0.2"
10
9
  platform: ruby
11
10
  authors:
12
11
  - !binary |