Skip to content

Commit

Permalink
Merge pull request #11 from Talkdesk/ivoanjo/v1.1.0
Browse files Browse the repository at this point in the history
Modernize gem + prepare v1.1.0 release
  • Loading branch information
ivoanjo authored Oct 9, 2022
2 parents c0adc55 + f006ab6 commit c62463c
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This is the default added code owner and should be changed or overridden.
# This will be the default owner for everything in the repo, unless a
# later match takes precedence
* @Talkdesk/octo
* @Talkdesk/octo @ivoanjo
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/.bundle/
/.yardoc
/Gemfile.lock
/gems.locked
/_yardoc/
/coverage/
/doc/
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
jruby-9.1.12.0
jruby-9.3.8.0
6 changes: 6 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ On kubernetes, you can make use of
https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/[readiness
probes] to delay service startup while warm-blanket is working.

=== Important for TruffleRuby as well!

TruffleRuby can be run either on a standalone mode, or with a JVM.
In either configuration, like JRuby, it needs to warm up until it
gets to peak performance, so WarmBlanket is great there too!

== How can I make use of it?

To make use of WarmBlanket, you'll need to follow the next sections,
Expand Down
2 changes: 1 addition & 1 deletion bin/pry
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../gems.rb',
Pathname.new(__FILE__).realpath)

require 'rubygems'
Expand Down
2 changes: 1 addition & 1 deletion bin/rspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../gems.rb',
Pathname.new(__FILE__).realpath)

require 'rubygems'
Expand Down
44 changes: 44 additions & 0 deletions examples/example_app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require "webrick"
require "pry"
require "warm-blanket"
require "logging"

puts "Using #{RUBY_DESCRIPTION}"

PORT = ENV["PORT"] || 8080

Logging.logger.root.add_appenders(Logging.appenders.stdout(
layout: Logging.layouts.pattern(pattern: '[%d] %-5l %c: %m\n', date_pattern: '%Y-%m-%d %H:%M:%S')
))

WarmBlanket.configure do |config|
common_headers = {
"X-Api-Key": "test-api-key",
}

config.port = PORT
config.endpoints = [
{get: "/foo", headers: common_headers},
{get: "/", headers: common_headers},
]
config.enabled = true
config.warmup_time_seconds = 3
end

WarmBlanket.trigger_warmup

server = WEBrick::HTTPServer.new(Port: PORT)

server.mount_proc("/") do |request, response|
response.body = "/ endpoint"
end

server.mount_proc("/foo") do |request, response|
response.body = "/foo endpoint"
end

trap("INT") do
server.shutdown
end

server.start
File renamed without changes.
8 changes: 8 additions & 0 deletions lib/warm-blanket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
module WarmBlanket
extend Dry::Configurable

# Compatibility with Ruby 2.3 / JRuby 9.1: Modern versions of dry-configurable emit deprecation warnings for the way
# we're passing in defaults, but older versions of the gem don't work on the older Ruby/JRuby versions.
# See https://github.com/dry-rb/dry-configurable/blob/main/CHANGELOG.md#0130-2021-09-12 .
# This can be dropped when we drop support for Ruby 2.3/JRuby 9.1
if Dry::Configurable.respond_to?(:warn_on_setting_positional_default)
Dry::Configurable.warn_on_setting_positional_default(false)
end

# Endpoints to be called for warmup, see README
setting :endpoints, [], reader: true

Expand Down
2 changes: 1 addition & 1 deletion lib/warm_blanket/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
# frozen_string_literal: true

module WarmBlanket
VERSION = '1.0.0'
VERSION = '1.1.0'
end
1 change: 0 additions & 1 deletion spec/integration/wait_for_port_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@

it 'retries until the time_deadline has passed' do
Timecop.freeze(Time.local(2017))
advancing_time = Time.now

expect(TCPSocket).to receive(:new).exactly(expected_tries).times do
tick_clock_one_second
Expand Down
26 changes: 18 additions & 8 deletions warm-blanket.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,29 @@ Gem::Specification.new do |spec|
spec.description = 'Ruby gem for warming up web services on boot'
spec.homepage = 'https://github.com/Talkdesk/warm-blanket'

spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0")
.reject { |f| f.match(%r{\A(?:test|spec|features|[.]github|examples)/}) }
.reject { |f|
["gems.rb", ".ruby-version", ".gitignore", ".rspec",
"Rakefile", "bin/pry", "bin/rspec", "bin/console"].include?(f)
}
end
spec.require_paths = ['lib']

spec.add_development_dependency 'bundler', '~> 1.15'
spec.add_development_dependency 'rspec', '~> 3.6'
spec.add_development_dependency 'webmock', '~> 3.0'
spec.required_ruby_version = ">= 2.3.0"

spec.add_development_dependency 'bundler', '~> 2.3'
spec.add_development_dependency 'rspec', '~> 3.11'
spec.add_development_dependency 'webmock', '~> 3.18'
spec.add_development_dependency 'timecop', '~> 0.9'
spec.add_development_dependency 'rake', '~> 12.0'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'pry-byebug' unless RUBY_PLATFORM == 'java'
spec.add_development_dependency 'pry-debugger-jruby' if RUBY_PLATFORM == 'java'
spec.add_development_dependency 'webrick', '~> 1.7.0'

spec.add_dependency 'faraday', '~> 0.9'
spec.add_dependency 'dry-configurable', '~> 0.7'
spec.add_dependency 'logging', '~> 2.1'
spec.add_dependency 'faraday', '~> 1.0' # Kept at 1.0 because it still supports Ruby 2.3 (JRuby 9.1)
spec.add_dependency 'dry-configurable', '~> 0.8' # Kept at 0.8 because it still supports Ruby 2.3 (JRuby 9.1)
spec.add_dependency 'logging', '~> 2.3'
end

0 comments on commit c62463c

Please sign in to comment.