timed_rest_for_chef 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -0
- data/lib/timed_rest_for_chef.rb +36 -0
- data/timed_rest_for_chef.gemspec +12 -0
- metadata +49 -0
data/README.md
ADDED
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
require 'chef/rest/rest_request'
|
3
|
+
|
4
|
+
if(Gem::Version.new(Chef::VERSION) < Gem::Version.new('10.14.0'))
|
5
|
+
|
6
|
+
# Custom timeout class to make it easy to log
|
7
|
+
# this specific type of timeout
|
8
|
+
class RESTTimeout < Timeout::Error
|
9
|
+
end
|
10
|
+
|
11
|
+
module TimedRestForChef
|
12
|
+
def timed_call
|
13
|
+
begin
|
14
|
+
Timeout::timeout(config[:rest_timeout], RESTTimeout) do
|
15
|
+
puts '*' * 100
|
16
|
+
puts "CALLING IN WRAP"
|
17
|
+
original_call
|
18
|
+
end
|
19
|
+
rescue => e
|
20
|
+
if(e.is_a?(WrapperTimeout))
|
21
|
+
Chef::Log.warn "Maximum request timeout has been reached"
|
22
|
+
end
|
23
|
+
raise
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.included(base)
|
28
|
+
base.class_eval do
|
29
|
+
alias_method :original_call, :call
|
30
|
+
alias_method :call, :timed_call
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
Chef::REST::RESTRequest.send(:include, TimedRestForChef)
|
36
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'timed_rest_for_chef'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.summary = 'Timed REST for Chef'
|
5
|
+
s.author = 'Chris Roberts'
|
6
|
+
s.email = 'chrisroberts.code@gmail.com'
|
7
|
+
s.homepage = 'http://github.com/chrisroberts/timed_rest_for_chef'
|
8
|
+
s.description = 'Timed REST for Chef'
|
9
|
+
s.require_path = 'lib'
|
10
|
+
s.extra_rdoc_files = ['README.md']
|
11
|
+
s.files = Dir.glob('**/*')
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: timed_rest_for_chef
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Roberts
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-18 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Timed REST for Chef
|
15
|
+
email: chrisroberts.code@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files:
|
19
|
+
- README.md
|
20
|
+
files:
|
21
|
+
- README.md
|
22
|
+
- timed_rest_for_chef.gemspec
|
23
|
+
- lib/timed_rest_for_chef.rb
|
24
|
+
homepage: http://github.com/chrisroberts/timed_rest_for_chef
|
25
|
+
licenses: []
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 1.8.17
|
45
|
+
signing_key:
|
46
|
+
specification_version: 3
|
47
|
+
summary: Timed REST for Chef
|
48
|
+
test_files: []
|
49
|
+
has_rdoc:
|