resque-noti-failure 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.8.7"
4
+ - "1.9.2"
5
+ - "1.9.3"
6
+ - "2.0.0"
7
+ services:
8
+ - redis-server
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+
9
+ gem "noti"
10
+ gem "resque"
11
+
12
+ group :development do
13
+ gem "shoulda"
14
+ gem "mocha"
15
+ gem "rdoc"
16
+ gem "bundler"
17
+ gem "jeweler"
18
+ end
19
+
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.2.13)
5
+ i18n (= 0.6.1)
6
+ multi_json (~> 1.0)
7
+ bourne (1.4.0)
8
+ mocha (~> 0.13.2)
9
+ git (1.2.5)
10
+ i18n (0.6.1)
11
+ jeweler (1.8.4)
12
+ bundler (~> 1.0)
13
+ git (>= 1.2.5)
14
+ rake
15
+ rdoc
16
+ json (1.7.7)
17
+ metaclass (0.0.1)
18
+ mocha (0.13.3)
19
+ metaclass (~> 0.0.1)
20
+ mono_logger (1.0.0)
21
+ multi_json (1.7.2)
22
+ noti (1.0.2)
23
+ json
24
+ rack (1.5.2)
25
+ rack-protection (1.5.0)
26
+ rack
27
+ rake (10.0.4)
28
+ rdoc (4.0.1)
29
+ json (~> 1.4)
30
+ redis (3.0.3)
31
+ redis-namespace (1.2.1)
32
+ redis (~> 3.0.0)
33
+ resque (1.24.1)
34
+ mono_logger (~> 1.0)
35
+ multi_json (~> 1.0)
36
+ redis-namespace (~> 1.2)
37
+ sinatra (>= 0.9.2)
38
+ vegas (~> 0.1.2)
39
+ shoulda (3.4.0)
40
+ shoulda-context (~> 1.0, >= 1.0.1)
41
+ shoulda-matchers (~> 1.0, >= 1.4.1)
42
+ shoulda-context (1.0.2)
43
+ shoulda-matchers (1.5.6)
44
+ activesupport (>= 3.0.0)
45
+ bourne (~> 1.3)
46
+ sinatra (1.4.2)
47
+ rack (~> 1.5, >= 1.5.2)
48
+ rack-protection (~> 1.4)
49
+ tilt (~> 1.3, >= 1.3.4)
50
+ tilt (1.3.6)
51
+ vegas (0.1.11)
52
+ rack (>= 1.0.0)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ bundler
59
+ jeweler
60
+ mocha
61
+ noti
62
+ rdoc
63
+ resque
64
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Jean-Philippe Lecaille
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,51 @@
1
+ == Resque Noti Failure
2
+
3
+ Sends resque failure to noti (http://notiapp.com), a tool allowing you to receive job failure directly on you desktop.
4
+
5
+ == Installation
6
+
7
+ You can let bundler install Resque Noti Failure by adding this line to your application's Gemfile:
8
+
9
+ gem 'resque-noti-failure'
10
+
11
+ And then execute:
12
+
13
+ bundle install
14
+
15
+ Or install it yourself with:
16
+
17
+ gem install resque-noti-failure
18
+
19
+ == Configuration
20
+
21
+ Before using this gem, you'll need registering your application to noti (https://notiapp.com/apps) and adding your API Key :
22
+
23
+ Noti.app = 'your-api-key'
24
+
25
+ Then you need to add a new failure backend to resque (more info about this on https://github.com/resque/resque/wiki/Failure-Backends) :
26
+
27
+ Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Plugins::NotiFailure::Failure]
28
+ Resque::Failure.backend = Resque::Failure::Multiple
29
+
30
+
31
+ == Build status
32
+
33
+ {<img src="https://travis-ci.org/jpl/resque-noti-failure.png?branch=master" alt="Build Status" />}[https://travis-ci.org/jpl/resque-noti-failure]
34
+ {<img src="https://codeclimate.com/github/jpl/resque-noti-failure.png" />}[https://codeclimate.com/github/jpl/resque-noti-failure]
35
+ {<img src="https://gemnasium.com/jpl/resque-noti-failure.png" alt="Dependency Status" />}[https://gemnasium.com/jpl/resque-noti-failure]
36
+
37
+ == Contributing to resque-noti
38
+
39
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
40
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
41
+ * Fork the project.
42
+ * Start a feature/bugfix branch.
43
+ * Commit and push until you are happy with your contribution.
44
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
45
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
46
+
47
+ == Copyright
48
+
49
+ Copyright (c) 2013 Jean-Philippe Lecaille. See LICENSE.txt for
50
+ further details.
51
+
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "resque-noti-failure"
18
+ gem.homepage = "https://github.com/jpl/resque-noti-failure"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Send noti (https://notiapp.com/) notification from resque failure}
21
+ # gem.description = %Q{TODO: longer description of your gem}
22
+ gem.email = "jpl@idol.io"
23
+ gem.authors = ["Jean-Philippe Lecaille"]
24
+ # dependencies defined in Gemfile
25
+ gem.add_dependency 'noti'
26
+ gem.add_dependency 'resque'
27
+ end
28
+ Jeweler::RubygemsDotOrgTasks.new
29
+
30
+ require 'rake/testtask'
31
+ Rake::TestTask.new(:test) do |test|
32
+ test.libs << 'lib' << 'test'
33
+ test.pattern = 'test/**/test_*.rb'
34
+ test.verbose = true
35
+ end
36
+
37
+ task :default => :test
38
+
39
+ require 'rdoc/task'
40
+ Rake::RDocTask.new do |rdoc|
41
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
42
+
43
+ rdoc.rdoc_dir = 'rdoc'
44
+ rdoc.title = "resque-noti-failure #{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,12 @@
1
+ require 'noti'
2
+ require 'resque'
3
+
4
+ module Resque
5
+ module Plugins
6
+ module NotiFailure
7
+ require 'resque/plugins/noti_failure/server'
8
+ require 'resque/plugins/noti_failure/failure'
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,28 @@
1
+ module Resque
2
+ module Plugins
3
+ module NotiFailure
4
+ class Failure < Resque::Failure::Base
5
+ def self.count(queue = nil, class_name = nil)
6
+ # We can't get the total # of errors from Noti so we fake it
7
+ # by asking Resque how many errors it has seen.
8
+ Stat[:failed]
9
+ end
10
+
11
+ def save
12
+ notification = ::Noti::Notification.new
13
+ notification.title = 'resque'
14
+ notification.text = "#{payload['class'].to_s}\n#{payload['args'].inspect}"
15
+ notification.url = Resque::Failure.url
16
+
17
+ Resque.redis.smembers('noti-users').each do |token|
18
+ begin
19
+ notification.deliver_to token
20
+ rescue Noti::Errors::AccessDenied
21
+ Resque.redis.srem('noti-users', token)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,66 @@
1
+ require 'resque/server'
2
+
3
+ module Resque
4
+ module Plugins
5
+ module NotiFailure
6
+ module Server
7
+ def self.erb_path(filename)
8
+ File.join(File.dirname(__FILE__), 'server', 'views', filename)
9
+ end
10
+
11
+ def self.included(base)
12
+ base.class_eval do
13
+ get '/noti/subscribe' do
14
+ token = ::Noti::Token.create_request_token(to('/noti/confirm'))
15
+ response.set_cookie('noti-request', token.request_token)
16
+ redirect token.redirect_url
17
+ end
18
+
19
+ get '/noti/confirm' do
20
+ cookie = request.cookies['noti-request']
21
+
22
+ unless cookie.nil?
23
+ access_token = ::Noti::Token.get_access_token(cookie)
24
+ Resque.redis.sadd('noti-users', access_token)
25
+ response.delete_cookie('noti-request')
26
+ end
27
+
28
+ redirect url_path('noti')
29
+ end
30
+
31
+ get '/noti' do
32
+ erb File.read(Resque::Plugins::NotiFailure::Server.erb_path('noti.erb'))
33
+ end
34
+
35
+ get '/noti/test' do
36
+ puts "Failure url : #{Resque::Failure.url}"
37
+
38
+ notification = Noti::Notification.new
39
+ notification.title = 'Test from resque'
40
+ notification.text = 'Some further information about this notification'
41
+ notification.url = to('/failed')
42
+ notification.sound = 'alert1'
43
+ notification.image = 'example'
44
+
45
+ Resque.redis.smembers('noti-users').each do |token|
46
+ begin
47
+ notification.deliver_to token
48
+ rescue Noti::Errors::AccessDenied
49
+ Resque.redis.srem('noti-users', token)
50
+ end
51
+ end
52
+
53
+ redirect url_path('noti')
54
+ end
55
+
56
+ Resque::Server.tabs << 'Noti'
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ Resque::Server.class_eval do
65
+ include Resque::Plugins::NotiFailure::Server
66
+ end
@@ -0,0 +1,28 @@
1
+ <style>
2
+ .noti small {
3
+ color: #999;
4
+ font-size: 85%;
5
+ line-height: 1.5;
6
+ padding-top: 10px;
7
+ }
8
+ </style>
9
+ <div class="noti">
10
+ <div class="title clearfix">
11
+ <h1>Noti</h1>
12
+ </div>
13
+ <% if Noti.app.nil? %>
14
+ <p>
15
+ In order to communicate with the service, you will need to create your own Noti account and create an application. Once the application has been created you should set the application key as shown (replacing the key shown with the key you are provided with when you create your app):
16
+ </p>
17
+ <p style='font-family:Monaco;'>
18
+ Noti.app = '7f38ce2d-8d9a-25dd-e167-8f8a711b81f8'
19
+ </p>
20
+ <% else %>
21
+ <p class='subscribe'>
22
+ <a href="noti/subscribe">Subscribe</a><br/>
23
+ <small>
24
+ Start receiving notifications on resque failures
25
+ </small>
26
+ </p>
27
+ <% end %>
28
+ </div>
@@ -0,0 +1,78 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "resque-noti-failure"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jean-Philippe Lecaille"]
12
+ s.date = "2013-03-31"
13
+ s.email = "jpl@idol.io"
14
+ s.extra_rdoc_files = [
15
+ "LICENSE.txt",
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".travis.yml",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/resque-noti-failure.rb",
28
+ "lib/resque/plugins/noti_failure/failure.rb",
29
+ "lib/resque/plugins/noti_failure/server.rb",
30
+ "lib/resque/plugins/noti_failure/server/views/noti.erb",
31
+ "resque-noti-failure.gemspec",
32
+ "test/helper.rb",
33
+ "test/redis-test.conf",
34
+ "test/test_failure.rb"
35
+ ]
36
+ s.homepage = "https://github.com/jpl/resque-noti-failure"
37
+ s.licenses = ["MIT"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = "1.8.25"
40
+ s.summary = "Send noti (https://notiapp.com/) notification from resque failure"
41
+
42
+ if s.respond_to? :specification_version then
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<noti>, [">= 0"])
47
+ s.add_runtime_dependency(%q<resque>, [">= 0"])
48
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
49
+ s.add_development_dependency(%q<mocha>, [">= 0"])
50
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
51
+ s.add_development_dependency(%q<bundler>, [">= 0"])
52
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
53
+ s.add_runtime_dependency(%q<noti>, [">= 0"])
54
+ s.add_runtime_dependency(%q<resque>, [">= 0"])
55
+ else
56
+ s.add_dependency(%q<noti>, [">= 0"])
57
+ s.add_dependency(%q<resque>, [">= 0"])
58
+ s.add_dependency(%q<shoulda>, [">= 0"])
59
+ s.add_dependency(%q<mocha>, [">= 0"])
60
+ s.add_dependency(%q<rdoc>, [">= 0"])
61
+ s.add_dependency(%q<bundler>, [">= 0"])
62
+ s.add_dependency(%q<jeweler>, [">= 0"])
63
+ s.add_dependency(%q<noti>, [">= 0"])
64
+ s.add_dependency(%q<resque>, [">= 0"])
65
+ end
66
+ else
67
+ s.add_dependency(%q<noti>, [">= 0"])
68
+ s.add_dependency(%q<resque>, [">= 0"])
69
+ s.add_dependency(%q<shoulda>, [">= 0"])
70
+ s.add_dependency(%q<mocha>, [">= 0"])
71
+ s.add_dependency(%q<rdoc>, [">= 0"])
72
+ s.add_dependency(%q<bundler>, [">= 0"])
73
+ s.add_dependency(%q<jeweler>, [">= 0"])
74
+ s.add_dependency(%q<noti>, [">= 0"])
75
+ s.add_dependency(%q<resque>, [">= 0"])
76
+ end
77
+ end
78
+
data/test/helper.rb ADDED
@@ -0,0 +1,65 @@
1
+ # Mostly copied from Resque in order to have similar test environment.
2
+ # https://github.com/defunkt/resque/blob/master/test/test_helper.rb
3
+ dir = File.dirname(File.expand_path(__FILE__))
4
+
5
+ require 'rubygems'
6
+ require 'bundler'
7
+ begin
8
+ Bundler.setup(:default, :development)
9
+ rescue Bundler::BundlerError => e
10
+ $stderr.puts e.message
11
+ $stderr.puts "Run `bundle install` to install missing gems"
12
+ exit e.status_code
13
+ end
14
+ require 'test/unit'
15
+ require 'shoulda'
16
+ require 'mocha/setup'
17
+
18
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
19
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
20
+ require 'resque'
21
+ require 'resque-noti-failure'
22
+
23
+ unless ENV['TRAVIS']
24
+ #
25
+ # make sure we can run redis
26
+ #
27
+
28
+ if !system("which redis-server")
29
+ puts '', "** can't find `redis-server` in your path"
30
+ puts "** try running `sudo rake install`"
31
+ abort ''
32
+ end
33
+
34
+ at_exit do
35
+ next if $!
36
+
37
+ if defined?(MiniTest)
38
+ exit_code = MiniTest::Unit.new.run(ARGV)
39
+ else
40
+ exit_code = Test::Unit::AutoRunner.run
41
+ end
42
+
43
+ pid = `ps -A -o pid,command | grep [r]edis-test`.split(" ")[0]
44
+ puts "Killing test redis server..."
45
+ `rm -f #{dir}/dump.rdb`
46
+ Process.kill("KILL", pid.to_i)
47
+ exit exit_code
48
+ end
49
+
50
+ puts "Starting redis for testing at localhost:9736..."
51
+ `redis-server #{dir}/redis-test.conf`
52
+ Resque.redis = 'localhost:9736'
53
+ else
54
+ Resque.redis = 'localhost:6379'
55
+ end
56
+
57
+ class BadJob
58
+ def self.perform(name=nil)
59
+ msg = name ? "Bad job, #{name}" : "Bad job!"
60
+ raise msg
61
+ end
62
+ end
63
+
64
+ class Test::Unit::TestCase
65
+ end
@@ -0,0 +1,115 @@
1
+ # Redis configuration file example
2
+
3
+ # By default Redis does not run as a daemon. Use 'yes' if you need it.
4
+ # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
5
+ daemonize yes
6
+
7
+ # When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
8
+ # You can specify a custom pid file location here.
9
+ pidfile ./test/redis-test.pid
10
+
11
+ # Accept connections on the specified port, default is 6379
12
+ port 9736
13
+
14
+ # If you want you can bind a single interface, if the bind option is not
15
+ # specified all the interfaces will listen for connections.
16
+ #
17
+ # bind 127.0.0.1
18
+
19
+ # Close the connection after a client is idle for N seconds (0 to disable)
20
+ timeout 300
21
+
22
+ # Save the DB on disk:
23
+ #
24
+ # save <seconds> <changes>
25
+ #
26
+ # Will save the DB if both the given number of seconds and the given
27
+ # number of write operations against the DB occurred.
28
+ #
29
+ # In the example below the behaviour will be to save:
30
+ # after 900 sec (15 min) if at least 1 key changed
31
+ # after 300 sec (5 min) if at least 10 keys changed
32
+ # after 60 sec if at least 10000 keys changed
33
+ save 900 1
34
+ save 300 10
35
+ save 60 10000
36
+
37
+ # The filename where to dump the DB
38
+ dbfilename dump.rdb
39
+
40
+ # For default save/load DB in/from the working directory
41
+ # Note that you must specify a directory not a file name.
42
+ dir ./test/
43
+
44
+ # Set server verbosity to 'debug'
45
+ # it can be one of:
46
+ # debug (a lot of information, useful for development/testing)
47
+ # notice (moderately verbose, what you want in production probably)
48
+ # warning (only very important / critical messages are logged)
49
+ loglevel debug
50
+
51
+ # Specify the log file name. Also 'stdout' can be used to force
52
+ # the demon to log on the standard output. Note that if you use standard
53
+ # output for logging but daemonize, logs will be sent to /dev/null
54
+ logfile stdout
55
+
56
+ # Set the number of databases. The default database is DB 0, you can select
57
+ # a different one on a per-connection basis using SELECT <dbid> where
58
+ # dbid is a number between 0 and 'databases'-1
59
+ databases 16
60
+
61
+ ################################# REPLICATION #################################
62
+
63
+ # Master-Slave replication. Use slaveof to make a Redis instance a copy of
64
+ # another Redis server. Note that the configuration is local to the slave
65
+ # so for example it is possible to configure the slave to save the DB with a
66
+ # different interval, or to listen to another port, and so on.
67
+
68
+ # slaveof <masterip> <masterport>
69
+
70
+ ################################## SECURITY ###################################
71
+
72
+ # Require clients to issue AUTH <PASSWORD> before processing any other
73
+ # commands. This might be useful in environments in which you do not trust
74
+ # others with access to the host running redis-server.
75
+ #
76
+ # This should stay commented out for backward compatibility and because most
77
+ # people do not need auth (e.g. they run their own servers).
78
+
79
+ # requirepass foobared
80
+
81
+ ################################### LIMITS ####################################
82
+
83
+ # Set the max number of connected clients at the same time. By default there
84
+ # is no limit, and it's up to the number of file descriptors the Redis process
85
+ # is able to open. The special value '0' means no limts.
86
+ # Once the limit is reached Redis will close all the new connections sending
87
+ # an error 'max number of clients reached'.
88
+
89
+ # maxclients 128
90
+
91
+ # Don't use more memory than the specified amount of bytes.
92
+ # When the memory limit is reached Redis will try to remove keys with an
93
+ # EXPIRE set. It will try to start freeing keys that are going to expire
94
+ # in little time and preserve keys with a longer time to live.
95
+ # Redis will also try to remove objects from free lists if possible.
96
+ #
97
+ # If all this fails, Redis will start to reply with errors to commands
98
+ # that will use more memory, like SET, LPUSH, and so on, and will continue
99
+ # to reply to most read-only commands like GET.
100
+ #
101
+ # WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
102
+ # 'state' server or cache, not as a real DB. When Redis is used as a real
103
+ # database the memory usage will grow over the weeks, it will be obvious if
104
+ # it is going to use too much memory in the long run, and you'll have the time
105
+ # to upgrade. With maxmemory after the limit is reached you'll start to get
106
+ # errors for write operations, and this may even lead to DB inconsistency.
107
+
108
+ # maxmemory <bytes>
109
+
110
+ ############################### ADVANCED CONFIG ###############################
111
+
112
+ # Glue small output buffers together in order to send small replies in a
113
+ # single TCP packet. Uses a bit more CPU but most of the times it is a win
114
+ # in terms of number of queries per second. Use 'yes' if unsure.
115
+ glueoutputbuf yes
@@ -0,0 +1,29 @@
1
+ require 'helper'
2
+
3
+ class TestFailure < Test::Unit::TestCase
4
+ context "Noti" do
5
+ setup do
6
+ Resque.redis.sadd('noti-users', 'user1')
7
+ Resque.redis.sadd('noti-users', 'user2')
8
+ end
9
+
10
+ should "should be notified of an error" do
11
+ exception = StandardError.new("BOOM")
12
+ worker = Resque::Worker.new(:test)
13
+ queue = "test"
14
+ payload = {'class' => Object, 'args' => 66}
15
+
16
+ ::Noti::Notification.any_instance.expects(:text=).with(regexp_matches(/Object/))
17
+ ::Noti::Notification.any_instance.expects(:deliver_to).twice.with(any_of('user1', 'user2'))
18
+
19
+ backend = Resque::Plugins::NotiFailure::Failure.new(exception, worker, queue, payload)
20
+ backend.save
21
+ end
22
+
23
+ should "not raise on count" do
24
+ assert_nothing_raised do
25
+ Resque::Plugins::NotiFailure::Failure.count
26
+ end
27
+ end
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,210 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque-noti-failure
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jean-Philippe Lecaille
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: noti
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: resque
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
+ - !ruby/object:Gem::Dependency
47
+ name: shoulda
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: mocha
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rdoc
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: bundler
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: jeweler
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: noti
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: resque
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ description:
159
+ email: jpl@idol.io
160
+ executables: []
161
+ extensions: []
162
+ extra_rdoc_files:
163
+ - LICENSE.txt
164
+ - README.rdoc
165
+ files:
166
+ - .document
167
+ - .travis.yml
168
+ - Gemfile
169
+ - Gemfile.lock
170
+ - LICENSE.txt
171
+ - README.rdoc
172
+ - Rakefile
173
+ - VERSION
174
+ - lib/resque-noti-failure.rb
175
+ - lib/resque/plugins/noti_failure/failure.rb
176
+ - lib/resque/plugins/noti_failure/server.rb
177
+ - lib/resque/plugins/noti_failure/server/views/noti.erb
178
+ - resque-noti-failure.gemspec
179
+ - test/helper.rb
180
+ - test/redis-test.conf
181
+ - test/test_failure.rb
182
+ homepage: https://github.com/jpl/resque-noti-failure
183
+ licenses:
184
+ - MIT
185
+ post_install_message:
186
+ rdoc_options: []
187
+ require_paths:
188
+ - lib
189
+ required_ruby_version: !ruby/object:Gem::Requirement
190
+ none: false
191
+ requirements:
192
+ - - ! '>='
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ segments:
196
+ - 0
197
+ hash: 2017228891349398639
198
+ required_rubygems_version: !ruby/object:Gem::Requirement
199
+ none: false
200
+ requirements:
201
+ - - ! '>='
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ requirements: []
205
+ rubyforge_project:
206
+ rubygems_version: 1.8.25
207
+ signing_key:
208
+ specification_version: 3
209
+ summary: Send noti (https://notiapp.com/) notification from resque failure
210
+ test_files: []