resque-oink 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'oink'
4
+
5
+ group :development do
6
+ gem "rspec", "~> 2.8.0"
7
+ gem "rdoc", "~> 3.12"
8
+ gem "bundler", "~> 1.0"
9
+ gem "jeweler", "~> 1.8.4"
10
+ gem "rcov", ">= 0"
11
+ end
@@ -0,0 +1,54 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.2.6)
5
+ activesupport (= 3.2.6)
6
+ builder (~> 3.0.0)
7
+ activerecord (3.2.6)
8
+ activemodel (= 3.2.6)
9
+ activesupport (= 3.2.6)
10
+ arel (~> 3.0.2)
11
+ tzinfo (~> 0.3.29)
12
+ activesupport (3.2.6)
13
+ i18n (~> 0.6)
14
+ multi_json (~> 1.0)
15
+ arel (3.0.2)
16
+ builder (3.0.0)
17
+ diff-lcs (1.1.3)
18
+ git (1.2.5)
19
+ hodel_3000_compliant_logger (0.1.0)
20
+ i18n (0.6.0)
21
+ jeweler (1.8.4)
22
+ bundler (~> 1.0)
23
+ git (>= 1.2.5)
24
+ rake
25
+ rdoc
26
+ json (1.7.3)
27
+ multi_json (1.3.6)
28
+ oink (0.9.3)
29
+ activerecord
30
+ hodel_3000_compliant_logger
31
+ rake (0.9.2.2)
32
+ rcov (1.0.0)
33
+ rdoc (3.12)
34
+ json (~> 1.4)
35
+ rspec (2.8.0)
36
+ rspec-core (~> 2.8.0)
37
+ rspec-expectations (~> 2.8.0)
38
+ rspec-mocks (~> 2.8.0)
39
+ rspec-core (2.8.0)
40
+ rspec-expectations (2.8.0)
41
+ diff-lcs (~> 1.1.2)
42
+ rspec-mocks (2.8.0)
43
+ tzinfo (0.3.33)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ bundler (~> 1.0)
50
+ jeweler (~> 1.8.4)
51
+ oink
52
+ rcov
53
+ rdoc (~> 3.12)
54
+ rspec (~> 2.8.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Rails Machine
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.
@@ -0,0 +1,32 @@
1
+ resque-oink
2
+ -----------
3
+
4
+ If using bundler, add to Gemfile:
5
+
6
+ gem 'resque-oink'
7
+
8
+ Or in Rails 2.3 land, add to `config/environment.rb`:
9
+
10
+ config.gem 'resque-oink'
11
+
12
+
13
+ Now, you can extend your job with `Resque::Plugins::Oink`. Following the [resque Archive example](https://github.com/defunkt/resque).
14
+
15
+ class Archive
16
+ extend Resque::Plugins::Oink
17
+
18
+ @queue = :file_serve
19
+
20
+ def self.perform(repo_id, branch = 'master')
21
+ repo = Repository.find(repo_id)
22
+ repo.create_archive(branch)
23
+ end
24
+ end
25
+
26
+
27
+ Copyright
28
+ =========
29
+
30
+ Copyright (c) 2012 Rails Machine. See LICENSE.txt for
31
+ further details.
32
+
@@ -0,0 +1,49 @@
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-oink"
18
+ gem.homepage = "http://github.com/railsmachine/resque-oink"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Resque extension for memory debugging}
21
+ gem.description = %Q{Resque extension to identify jobs which significantly increase VM heap size using oink}
22
+ gem.email = "josh@technicalpickles.com"
23
+ gem.authors = ["Josh Nichols"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "resque-oink #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1 @@
1
+ require 'resque/plugins/oink'
@@ -0,0 +1,41 @@
1
+ require 'oink'
2
+ require 'oink/utils/hash_utils'
3
+ require 'oink/instrumentation'
4
+ require 'oink/instrumentation/active_record'
5
+ require 'hodel_3000_compliant_logger'
6
+
7
+ ActiveRecord::Base.send(:include, Oink::Instrumentation::ActiveRecord)
8
+ module Resque
9
+ module Plugins
10
+ module Oink
11
+
12
+ def oink_logger
13
+ @oink_logger ||= Hodel3000CompliantLogger.new("log/resque-oink.log")
14
+ end
15
+
16
+
17
+ def before_perform_with_oink_instrumentation(*args)
18
+ ActiveRecord::Base.reset_instance_type_count
19
+ end
20
+
21
+ def after_perform_with_oink_instrumentation(*args)
22
+ job_class = if self.kind_of?(Class)
23
+ self.name
24
+ else
25
+ self.class.name
26
+ end
27
+ oink_logger.info "Oink Action: #{job_class}#perform"
28
+ memory = ::Oink::Instrumentation::MemorySnapshot.memory
29
+ oink_logger.info "Memory usage: #{memory} | PID: #{$$}"
30
+
31
+ sorted_list = ::Oink::HashUtils.to_sorted_array(ActiveRecord::Base.instantiated_hash)
32
+ sorted_list.unshift("Total: #{ActiveRecord::Base.total_objects_instantiated}")
33
+
34
+ oink_logger.info "Instantiation Breakdown: #{sorted_list.join(' | ')}"
35
+
36
+ oink_logger.info("Oink Log Entry Complete")
37
+
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,67 @@
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-oink"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Josh Nichols"]
12
+ s.date = "2012-06-22"
13
+ s.description = "Resque extension to identify jobs which significantly increase VM heap size using oink"
14
+ s.email = "josh@technicalpickles.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/resque-oink.rb",
29
+ "lib/resque/plugins/oink.rb",
30
+ "resque-oink.gemspec",
31
+ "spec/resque-oink_spec.rb",
32
+ "spec/spec_helper.rb"
33
+ ]
34
+ s.homepage = "http://github.com/railsmachine/resque-oink"
35
+ s.licenses = ["MIT"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = "1.8.15"
38
+ s.summary = "Resque extension for memory debugging"
39
+
40
+ if s.respond_to? :specification_version then
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<oink>, [">= 0"])
45
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
46
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
47
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
48
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
49
+ s.add_development_dependency(%q<rcov>, [">= 0"])
50
+ else
51
+ s.add_dependency(%q<oink>, [">= 0"])
52
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
53
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
54
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
55
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
56
+ s.add_dependency(%q<rcov>, [">= 0"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<oink>, [">= 0"])
60
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
61
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
62
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
63
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
64
+ s.add_dependency(%q<rcov>, [">= 0"])
65
+ end
66
+ end
67
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "ResqueOink" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'resque-oink'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque-oink
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Josh Nichols
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-06-22 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 3
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ name: oink
31
+ prerelease: false
32
+ type: :runtime
33
+ requirement: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ hash: 47
41
+ segments:
42
+ - 2
43
+ - 8
44
+ - 0
45
+ version: 2.8.0
46
+ name: rspec
47
+ prerelease: false
48
+ type: :development
49
+ requirement: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ hash: 31
57
+ segments:
58
+ - 3
59
+ - 12
60
+ version: "3.12"
61
+ name: rdoc
62
+ prerelease: false
63
+ type: :development
64
+ requirement: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ version_requirements: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ hash: 15
72
+ segments:
73
+ - 1
74
+ - 0
75
+ version: "1.0"
76
+ name: bundler
77
+ prerelease: false
78
+ type: :development
79
+ requirement: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ version_requirements: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ hash: 63
87
+ segments:
88
+ - 1
89
+ - 8
90
+ - 4
91
+ version: 1.8.4
92
+ name: jeweler
93
+ prerelease: false
94
+ type: :development
95
+ requirement: *id005
96
+ - !ruby/object:Gem::Dependency
97
+ version_requirements: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ name: rcov
107
+ prerelease: false
108
+ type: :development
109
+ requirement: *id006
110
+ description: Resque extension to identify jobs which significantly increase VM heap size using oink
111
+ email: josh@technicalpickles.com
112
+ executables: []
113
+
114
+ extensions: []
115
+
116
+ extra_rdoc_files:
117
+ - LICENSE.txt
118
+ - README.md
119
+ files:
120
+ - .document
121
+ - .rspec
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - VERSION
128
+ - lib/resque-oink.rb
129
+ - lib/resque/plugins/oink.rb
130
+ - resque-oink.gemspec
131
+ - spec/resque-oink_spec.rb
132
+ - spec/spec_helper.rb
133
+ homepage: http://github.com/railsmachine/resque-oink
134
+ licenses:
135
+ - MIT
136
+ post_install_message:
137
+ rdoc_options: []
138
+
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 3
147
+ segments:
148
+ - 0
149
+ version: "0"
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ hash: 3
156
+ segments:
157
+ - 0
158
+ version: "0"
159
+ requirements: []
160
+
161
+ rubyforge_project:
162
+ rubygems_version: 1.8.15
163
+ signing_key:
164
+ specification_version: 3
165
+ summary: Resque extension for memory debugging
166
+ test_files: []
167
+