Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/liquidm/ext
Browse files Browse the repository at this point in the history
  • Loading branch information
adwinsky committed Feb 17, 2015
2 parents 8ea211e + 0bae091 commit c295de1
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ spec/reports
test/tmp
test/version_tmp
tmp
.idea
11 changes: 3 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
liquid-ext (3.5.2)
liquid-ext (3.5.4)
activesupport
erubis
jmx4r
Expand All @@ -12,14 +12,13 @@ PATH
GEM
remote: http://rubygems.org/
specs:
activesupport (4.1.5)
activesupport (4.1.7)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
awesome_print (1.2.0)
bond (0.5.1)
bond (0.5.1-java)
brice (0.2.9)
ruby-nuggets (>= 0.5.2)
Expand Down Expand Up @@ -56,15 +55,11 @@ GEM
yard
log_switch (0.4.0)
method_source (0.8.2)
minitest (5.4.0)
minitest (5.4.3)
mixlib-cli (1.5.0)
multi_json (1.10.1)
nokogiri (1.6.2.1-java)
parallel (1.0.0)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pry (0.9.12.6-java)
coderay (~> 1.0)
method_source (~> 0.8)
Expand Down
Binary file removed lib/liquid/curator-client-2.4.1.jar
Binary file not shown.
Binary file added lib/liquid/curator-client-2.7.1.jar
Binary file not shown.
Binary file removed lib/liquid/curator-framework-2.4.1.jar
Binary file not shown.
Binary file added lib/liquid/curator-framework-2.7.1.jar
Binary file not shown.
Binary file removed lib/liquid/curator-recipes-2.4.1.jar
Binary file not shown.
Binary file added lib/liquid/curator-recipes-2.7.1.jar
Binary file not shown.
Binary file removed lib/liquid/curator-test-2.4.1.jar
Binary file not shown.
Binary file added lib/liquid/curator-test-2.7.1.jar
Binary file not shown.
37 changes: 37 additions & 0 deletions lib/liquid/ext/shutdown.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Shutdown

# Receives a time span in seconds and a block which will be registered for execution when the program exits.
# If multiple hanlders are registered, they are executed in reverse order of registration.
#
# If a handler throws an exception or takes longer then the specified time span, execution skips to the next
# handler in line.
#
# If the first parameter is nil, the handler will not check the codes runtime. Be cautios when executing
# asynchronous code when the 'seconds' parameter set to nil value as blocking codes would prevent
# the process from terminating.
def self.register_handler_with_timeout(seconds, &block)
return unless block_given?
at_exit do
$log.info("shutdown", location: block.inspect) if $log
begin
Timeout::timeout(seconds, &block)
rescue => e
$log.exception e if $log
end
end
end


# Receives a block which will be registered for execution when the program exits.
# If multiple hanlders are registered, they are executed in reverse order of registration.
#
# with_handler will not check the execution duration of the given block so only
# use this for non_blocking code, use register_handler_with_timout if you make potentially
# blocking calls
def self.register_handler(&block)
return unless block_given?
self.register_handler_with_timeout(nil, &block)
end

end

3 changes: 3 additions & 0 deletions lib/liquid/ext/signal.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module Signal
# be cautious with this shutdown handler as it does not
# guarantee execution of all handlers and swallows exceptions
# inside handlers. Use Shutdown.register_with_handler instead
def self.register_shutdown_handler(&block)
signals = %w(INT TERM)

Expand Down
2 changes: 1 addition & 1 deletion liquid-ext.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |spec|
spec.name = 'liquid-ext'
spec.version = '3.5.2'
spec.version = '3.5.4'
spec.authors = ['LiquidM, Inc.']
spec.email = ['opensource@liquidm.com']
spec.description = %q{LiquidM ruby core extensions and helper libraries}
Expand Down

0 comments on commit c295de1

Please sign in to comment.