Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

**Enhancements:**

- [#31](github.com/castle/castle-ruby/pull/31/) remove auto-integration with Rails, Padrino, Sinatra (see BREAKING CHANGES, README)
- [#35](github.com/castle/castle-ruby/pull/35) dropped unused cookie store class, more informative Castle:Client constructor params
- [#30](github.com/castle/castle-ruby/pull/30) change request timeout to 500ms
- [#31](github.com/castle/castle-ruby/pull/31) remove auto-integration with Rails, Padrino, Sinatra (see BREAKING CHANGES, README)

**BREAKING CHANGES:**

- add `require 'castle/support/rails'` to have Castle client instance available as `castle` in your Rails controllers
- add `require 'castle/support/padrino'` to have Castle client instance available as `castle` in your Padrino helpers
- add `require 'castle/support/sinatra'` to have Castle client instance available as `castle` in your Sinatra helpers
- request timeout uses milliseconds unit from now on

**Features:**

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Castle.configure do |config|
# Same as setting it through Castle.api_secret
config.api_secret = 'secret'

# Castle::RequestError is raised when timing out (default: 30.0)
config.request_timeout = 2.0
# Castle::RequestError is raised when timing out in seconds (default: 500 milliseconds)
config.request_timeout = 2000

# For tracking in non-web environments: https://castle.io/docs/sources (default: 'web')
config.source_header = 'backend'
Expand Down
2 changes: 1 addition & 1 deletion lib/castle/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def prepare_http
@config_api_endpoint.host,
@config_api_endpoint.port
)
http.read_timeout = @config.request_timeout
http.read_timeout = @config.request_timeout / 1000.0
prepare_http_for_ssl(http) if @config_api_endpoint.scheme == 'https'
http
end
Expand Down
3 changes: 2 additions & 1 deletion lib/castle/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
module Castle
# manages configuration variables
class Configuration
REQUEST_TIMEOUT = 30.0
SUPPORTED = %i[source_header request_timeout api_secret api_endpoint].freeze
REQUEST_TIMEOUT = 500 # in milliseconds
API_ENDPOINT = 'https://api.castle.io/v1'
WHITELISTED = [
'User-Agent',
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/castle/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

describe 'request_timeout' do
it do
expect(config.request_timeout).to be_eql(30.0)
expect(config.request_timeout).to be_eql(500)
end

context 'setter' do
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
RSpec.configure do |config|
config.before(:each) do
Castle.config.api_endpoint = 'https://api.castle.io/v1'
Castle.config.request_timeout = 30.0
stub_request(:any, /api.castle.io/)
.to_return(status: 200, body: '{}', headers: {})
end
Expand Down