Skip to content

Commit 93e2f2f

Browse files
authored
Remove alerts (#116)
1 parent ae3a692 commit 93e2f2f

File tree

5 files changed

+0
-675
lines changed

5 files changed

+0
-675
lines changed

README.md

-150
Original file line numberDiff line numberDiff line change
@@ -455,36 +455,6 @@ Polling will automatically delete the message at the end of the block.
455455
```ruby
456456
queue.clear # => #<IronMQ::ResponseBase:...>
457457
```
458-
### Add an Alert to a Queue
459-
460-
[Check out our Blog Post on Queue Alerts](http://blog.iron.io).
461-
462-
Alerts have now been incorporated into IronMQ. This feature lets developers control actions based on the activity within a queue. With alerts, actions can be triggered when the number of messages in a queue reach a certain threshold. These actions can include things like auto-scaling, failure detection, load-monitoring, and system health.
463-
464-
You may add up to 5 alerts per queue.
465-
466-
**Required parameters:**
467-
* `type`: required - "fixed" or "progressive". In case of alert's type set to "fixed", alert will be triggered when queue size pass value set by trigger parameter. When type set to "progressive", alert will be triggered when queue size pass any of values, calculated by trigger * N where N >= 1. For example, if trigger set to 10, alert will be triggered at queue sizes 10, 20, 30, etc.
468-
* `direction`: required - "asc" or "desc". Set direction in which queue size must be changed when pass trigger value. If direction set to "asc" queue size must growing to trigger alert. When direction is "desc" queue size must decreasing to trigger alert.
469-
* `trigger`: required. It will be used to calculate actual values of queue size when alert must be triggered. See type field description. Trigger must be integer value greater than 0.
470-
* `queue`: required. Name of queue which will be used to post alert messages.
471-
472-
**Optional parameters:**
473-
474-
* `snooze`: Number of seconds between alerts. If alert must be triggered but snooze is still active, alert will be omitted. Snooze must be integer value greater than or equal to 0.
475-
476-
```ruby
477-
queue.add_alert({
478-
type: 'progressive',
479-
trigger: 10,
480-
queue: 'my_alert_queue',
481-
direction: 'asc',
482-
snooze: 0
483-
})
484-
queue.clear
485-
# => #<IronMQ::ResponseBase:0x007f95d3b25438 @raw={"msg"=>"Updated"}, @code=200>
486-
```
487-
488458

489459
--
490460

@@ -639,126 +609,6 @@ end
639609

640610
--
641611

642-
## Queue Alerts
643-
644-
Queue Alerts allow you to set queue's size levels which are critical
645-
for your application. For example, you want to start processing worker
646-
when queue size grows from 0 to 1. Then add alert of `type` "fixed",
647-
`direction` "asc", and `trigger` 1. In this case, if queue size changed
648-
from 0 to 1 alert message will be put on queue, set by `queue`
649-
parameter of alert's hash. If you want to prevent alerts to be put onto
650-
alert queue in some time after previous alert message - use `snooze`
651-
parameter. For example, to make alert silent in one hour, set `snooze`
652-
to 3600 (seconds).
653-
654-
**Note:** alerts feature are only avalable for Pull (or regular) Queues.
655-
656-
See [Queue Alerts](http://dev.iron.io/mq/reference/queue_alerts/) to learn more.
657-
658-
### Alerts Parameters
659-
660-
Alerts can be configured with the following parameters:
661-
662-
* `type`: string, required. Type of alert. Available types are "fixed"
663-
and "progressive".
664-
* `direction`: string, optional. Direction of queue fluctuations.
665-
Available directions are "asc" (alert will be triggered if queue
666-
size grows) and "desc" (alert will be triggered if queue size
667-
decreases). Defaults to "asc".
668-
* `trigger`: integer, required. Value which is used to calculate
669-
actual queue size when alert will be triggered. In case of "fixed"
670-
type of alert `trigger` itself represents actual queue size. When
671-
type of alert is "progressive", actual queue sizes are calculated by
672-
`trigger * N`, where `N` is integer greater than 0. For example,
673-
type is "progressive" and trigger is 100. Alert messages will be put
674-
on queue at sizes 100, 200, 300, ...
675-
* `queue`: string, required. Name of a queue which receives alert messages.
676-
* `snooze`: integer, optional. Represents number of seconds alert will
677-
be silent after latter message, put onto alert queue.
678-
679-
**Note:** IronMQ backend checks for alerts duplications each time you
680-
add new alerts to a queue. It compares `type`, `direction`, and
681-
`trigger` parameters to find duplicates. If one or more of new
682-
alerts duplicates existing, backend return `HTTP 400` error, message
683-
will be `{"msg": "At least one new alert duplicates current queue alerts."}`.
684-
685-
### Add Alerts to a Queue
686-
687-
To add single alert to a queue.
688-
689-
```ruby
690-
queue.add_alert({
691-
type: 'fixed',
692-
direction: 'asc',
693-
trigger: 1,
694-
queue: 'alerts-queue',
695-
snooze: 600
696-
})
697-
# => #<IronMQ::ResponseBase:0x007f8d22980420 @raw={"msg"=>"Alerts were added."}, @code=200>
698-
```
699-
700-
To add multiple alerts at a time.
701-
702-
```ruby
703-
queue.add_alerts([
704-
{
705-
type: 'fixed',
706-
direction: 'desc',
707-
trigger: 1,
708-
queue: 'alerts-queue'
709-
},
710-
{
711-
type: 'progressive',
712-
trigger: 1000,
713-
queue: 'critical-alerts-queue'
714-
}
715-
])
716-
# => #<IronMQ::ResponseBase:0x00abcdf1980420 @raw={"msg"=>"Alerts were added."}, @code=200>
717-
```
718-
719-
### Remove Alerts from a Queue
720-
721-
To remove single alert by its ID.
722-
723-
```ruby
724-
queue.remove_alert({ id: '5eee546df4a4140e8638a7e5' })
725-
# => #<IronMQ::ResponseBase:0x007f8d229a1878 @raw={"msg"=>"Alerts were deleted."}, @code=200>
726-
```
727-
728-
Remove multiple alerts by IDs.
729-
730-
```ruby
731-
queue.remove_alerts([
732-
{ id: '53060b541185ab3eaf04c83f' },
733-
{ id: '99a50b541185ab3eaf9bcfff' }
734-
])
735-
# => #<IronMQ::ResponseBase:0x093b8d229a18af @raw={"msg"=>"Alerts were deleted."}, @code=200>
736-
```
737-
738-
### Replace and Clear Alerts on a Queue
739-
740-
Following code sample shows how to replace alerts on a queue.
741-
742-
```ruby
743-
queue.replace_alerts([
744-
{
745-
type: 'fixed',
746-
trigger: 100,
747-
queue: 'alerts'
748-
}
749-
])
750-
# => #<IronMQ::ResponseBase:0x00008d229a16bf @raw={"msg"=>"Alerts were replaced."}, @code=200>
751-
```
752-
753-
To clear alerts on a queue.
754-
755-
```ruby
756-
queue.clear_alerts
757-
# => #<IronMQ::ResponseBase:0x87ad13ff3a18af @raw={"msg"=>"Alerts were replaced."}, @code=200>
758-
```
759-
760-
**Note:** `Queue#clear_alerts` is a helper, which represents
761-
`Queue#replace_alerts` call with empty `Array` of alerts.
762612

763613
## Important Notes
764614

lib/iron_mq.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require File.expand_path('iron_mq/response', File.dirname(__FILE__))
22
require File.expand_path('iron_mq/subscribers', File.dirname(__FILE__))
3-
require File.expand_path('iron_mq/alert', File.dirname(__FILE__))
43
require File.expand_path('iron_mq/queues', File.dirname(__FILE__))
54
require File.expand_path('iron_mq/messages', File.dirname(__FILE__))
65
require File.expand_path('iron_mq/client', File.dirname(__FILE__))

lib/iron_mq/alert.rb

-58
This file was deleted.

lib/iron_mq/queues.rb

-34
Original file line numberDiff line numberDiff line change
@@ -153,36 +153,6 @@ def subscribers(options = {})
153153
info['push']['subscribers'].map { |s| Subscriber.new(s, self, options) }
154154
end
155155

156-
def add_alerts(alerts)
157-
call_api_and_parse_response(:patch, '', queue: {alerts: alerts})
158-
end
159-
160-
def add_alert(alert)
161-
add_alerts([alert])
162-
end
163-
164-
def remove_alerts(alerts)
165-
call_api_and_parse_response(:delete, '/alerts', alerts: alerts)
166-
end
167-
168-
def remove_alert(alert)
169-
remove_alerts([alert])
170-
end
171-
172-
def replace_alerts(alerts)
173-
call_api_and_parse_response(:put, '/alerts', alerts: alerts)
174-
end
175-
176-
def clear_alerts
177-
replace_alerts([])
178-
end
179-
180-
def alerts
181-
load
182-
return nil unless @raw['alerts']
183-
to_alerts(@raw['alerts'])
184-
end
185-
186156
def post_messages(payload, options = {})
187157
batch = false
188158

@@ -292,10 +262,6 @@ def call_api_and_parse_response(meth, ext_path = '', options = {},
292262

293263
private
294264

295-
def to_alerts(alert_array)
296-
alert_array.each_with_object([]) { |a, res| res << Alert.new(self, a) }
297-
end
298-
299265
def path(ext_path)
300266
"/#{CGI::escape(@name).gsub('+', '%20')}#{ext_path}"
301267
end

0 commit comments

Comments
 (0)