killbill 3.1.10 → 3.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53241b3ff5ba7293ab885ae36942071b396cdb03
4
- data.tar.gz: 6c78b3cb59a3c28140b30fdfbcc080425858f5ce
3
+ metadata.gz: aabe3a8f982505fbc0553841a657da0c8594ce57
4
+ data.tar.gz: 794bbb1623029efe0eb5689457b940703b1d4282
5
5
  SHA512:
6
- metadata.gz: c131124735e38e0e61e7934190e36e661490df54d308d5bb8ffd74e743312b35e4561eec42f8bd9bd5df50a15e51746fd79966a72340e3ab93a680f24dfe74bf
7
- data.tar.gz: 3e69182738dba3c38f5f012afc6846b9306454c4e97e5cb70c1ac1a6f60cfdf8fe26c4f518a4aaeaf6e416246fc40e5176442df08cddfb8c62fcf84f2f30f89a
6
+ metadata.gz: 8d3ffd5609c96255b83964709465f29b1a16619a4fa00c585ac3d1c4ad6000ab08448c608c2987de3871925900f0f65385c2f16f36affe07313611e9d5c64837
7
+ data.tar.gz: 6bfaf6c5de3339383920799042f9054215e33538ff08f02cf61d463fbc91ef66ad8b30b94efa386126c9f515e255b7ea83e07c3b4330ffd69eeada56cb08bafb
data/NEWS CHANGED
@@ -1,3 +1,10 @@
1
+ 3.1.11
2
+ ActiveMerchant:
3
+ - add proxy support
4
+ - redirect wiredump device to Kill Bill log
5
+ - expose networking configuration options
6
+ ActiveRecord performance improvements
7
+
1
8
  3.1.10
2
9
  Add workarounds for ActiveRecord bugs under high load/concurrency
3
10
  BoundedLRUCache performance improvements
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.10
1
+ 3.1.11
@@ -35,6 +35,29 @@ module ActiveRecord
35
35
  def self.jndi_retries(config)
36
36
  (config[:jndi_retries] || 5).to_i
37
37
  end
38
+
39
+ protected
40
+
41
+ def setup_jndi_factory
42
+ data_source = config[:data_source] || Java::JavaxNaming::InitialContext.new.lookup(config[:jndi].to_s)
43
+
44
+ @jndi = true
45
+ # Really slow under high load (see https://github.com/jruby/activerecord-jdbc-adapter/pull/588).
46
+ #self.connection_factory = JdbcConnectionFactory.impl { data_source.connection }
47
+ self.connection_factory = RubyJdbcConnectionFactory.new(data_source)
48
+ end
49
+
50
+ class RubyJdbcConnectionFactory
51
+ include JdbcConnectionFactory
52
+
53
+ def initialize(data_source)
54
+ @data_source = data_source
55
+ end
56
+
57
+ def new_connection
58
+ @data_source.connection
59
+ end
60
+ end
38
61
  end
39
62
  end
40
63
  end
@@ -0,0 +1,58 @@
1
+ require 'active_utils/common/posts_data'
2
+
3
+ # Pass the proxy details to the connection object - see https://github.com/Shopify/active_utils/pull/44
4
+ module ActiveMerchant #:nodoc:
5
+ module PostsData #:nodoc:
6
+
7
+ def self.included(base)
8
+ base.superclass_delegating_accessor :ssl_strict
9
+ base.ssl_strict = true
10
+
11
+ base.superclass_delegating_accessor :ssl_version
12
+ base.ssl_version = nil
13
+
14
+ base.class_attribute :retry_safe
15
+ base.retry_safe = false
16
+
17
+ base.superclass_delegating_accessor :open_timeout
18
+ base.open_timeout = 60
19
+
20
+ base.superclass_delegating_accessor :read_timeout
21
+ base.read_timeout = 60
22
+
23
+ base.superclass_delegating_accessor :max_retries
24
+ base.max_retries = Connection::MAX_RETRIES
25
+
26
+ base.superclass_delegating_accessor :logger
27
+ base.superclass_delegating_accessor :wiredump_device
28
+
29
+ base.superclass_delegating_accessor :proxy_address
30
+ base.superclass_delegating_accessor :proxy_port
31
+ end
32
+
33
+ def raw_ssl_request(method, endpoint, data, headers = {})
34
+ logger.warn "#{self.class} using ssl_strict=false, which is insecure" if logger unless ssl_strict
35
+
36
+ connection = new_connection(endpoint)
37
+ connection.open_timeout = open_timeout
38
+ connection.read_timeout = read_timeout
39
+ connection.retry_safe = retry_safe
40
+ connection.verify_peer = ssl_strict
41
+ connection.ssl_version = ssl_version
42
+ connection.logger = logger
43
+ connection.max_retries = max_retries
44
+ connection.tag = self.class.name
45
+ connection.wiredump_device = wiredump_device
46
+
47
+ connection.pem = @options[:pem] if @options
48
+ connection.pem_password = @options[:pem_password] if @options
49
+
50
+ connection.ignore_http_status = @options[:ignore_http_status] if @options
51
+
52
+ connection.proxy_address = proxy_address
53
+ connection.proxy_port = proxy_port
54
+
55
+ connection.request(method, data, headers)
56
+ end
57
+ end
58
+ end
@@ -16,9 +16,11 @@ module ActiveMerchant
16
16
 
17
17
  result = nil
18
18
  realtime = Benchmark.realtime do
19
- options = {:method => method, :headers => headers}
20
- options[:body] = body if body
21
- result = http(endpoint.to_s, options)
19
+ options = {:method => method, :headers => headers, :connecttimeout => open_timeout}
20
+ options[:body] = body if body
21
+ options[:proxy] = proxy_address if proxy_address
22
+ options[:proxy] += ":#{proxy_port}" if proxy_address and proxy_port
23
+ result = http(endpoint.to_s, options)
22
24
  end
23
25
 
24
26
  debug '--> response_code=%d (body_length=%d total_time=%.4fs realtime=%.4fs)' % [result.code, result.body ? result.body.length : 0, result.total_time, realtime], tag
@@ -4,6 +4,7 @@ module Killbill
4
4
  require 'killbill'
5
5
 
6
6
  require 'killbill/ext/active_merchant/jdbc_connection'
7
+ require 'killbill/ext/active_merchant/proxy_support'
7
8
 
8
9
  require 'active_support/core_ext'
9
10
  require File.dirname(__FILE__) + '/active_merchant/core_ext.rb'
@@ -13,8 +13,20 @@ module Killbill
13
13
 
14
14
  if config[:log_file]
15
15
  ::ActiveMerchant::Billing::Gateway.wiredump_device = File.open(config[:log_file], 'w')
16
- ::ActiveMerchant::Billing::Gateway.wiredump_device.sync = true
16
+ else
17
+ log_method = config[:quiet] ? :debug : :info
18
+ ::ActiveMerchant::Billing::Gateway.wiredump_device = ::Killbill::Plugin::ActiveMerchant::Utils::KBWiredumpDevice.new(logger, log_method)
17
19
  end
20
+ ::ActiveMerchant::Billing::Gateway.wiredump_device.sync = true
21
+
22
+ ::ActiveMerchant::Billing::Gateway.open_timeout = config[:open_timeout] if config[:open_timeout]
23
+ ::ActiveMerchant::Billing::Gateway.read_timeout = config[:read_timeout] if config[:read_timeout]
24
+ ::ActiveMerchant::Billing::Gateway.retry_safe = config[:retry_safe] if config[:retry_safe]
25
+ ::ActiveMerchant::Billing::Gateway.ssl_strict = config[:ssl_strict] if config[:ssl_strict]
26
+ ::ActiveMerchant::Billing::Gateway.ssl_version = config[:ssl_version] if config[:ssl_version]
27
+ ::ActiveMerchant::Billing::Gateway.max_retries = config[:max_retries] if config[:max_retries]
28
+ ::ActiveMerchant::Billing::Gateway.proxy_address = config[:proxy_address] if config[:proxy_address]
29
+ ::ActiveMerchant::Billing::Gateway.proxy_port = config[:proxy_port] if config[:proxy_port]
18
30
 
19
31
  Gateway.new(config, gateway_builder.call(config))
20
32
  end
@@ -18,6 +18,8 @@ module Killbill
18
18
  end
19
19
 
20
20
  def start_plugin
21
+ @logger.progname = "#{@identifier.to_s}-plugin"
22
+
21
23
  ::Killbill::Plugin::ActiveMerchant.initialize! @gateway_builder,
22
24
  @identifier.to_sym,
23
25
  @logger,
@@ -17,6 +17,23 @@ module Killbill
17
17
  no_hyphens.insert(8, "-").insert(13, "-").insert(18, "-").insert(23, "-")
18
18
  end
19
19
 
20
+ class KBWiredumpDevice < IO
21
+
22
+ # Required for compatibility, but unused
23
+ attr_accessor :sync
24
+
25
+ def initialize(logger, method = :info)
26
+ @logger = logger
27
+ @method = method
28
+ end
29
+
30
+ # We mostly care about the << method
31
+ def write(string)
32
+ sanitized_string = string.to_s.chomp("\n")
33
+ @logger.send(@method, sanitized_string) if sanitized_string.size > 0
34
+ end
35
+ end
36
+
20
37
  # Relies on the fact that hashes enumerate their values in the order that the corresponding keys were inserted (Ruby 1.9+)
21
38
  class BoundedLRUCache
22
39
 
@@ -6,6 +6,7 @@ module Killbill
6
6
  class KillbillLogger
7
7
 
8
8
  attr_accessor :log_level
9
+ attr_accessor :progname
9
10
 
10
11
  def initialize(delegate)
11
12
  @logger = delegate
@@ -66,7 +67,8 @@ module Killbill
66
67
  message = '(nil)'
67
68
  end
68
69
  end
69
- message.nil? ? '(nil)' : message.to_s
70
+ final_message = message.nil? ? '(nil)' : message.to_s
71
+ @progname ? "[#{@progname}] #{final_message}" : final_message
70
72
  end
71
73
 
72
74
  alias_method :fatal, :error
@@ -20,6 +20,22 @@ describe Killbill::Plugin::ActiveMerchant::Utils do
20
20
  end
21
21
  end
22
22
 
23
+ it 'should implement a wiredump device for the Kill Bill logger' do
24
+ logger = Logger.new(STDOUT)
25
+ logger.level = Logger::INFO
26
+
27
+ io = ::Killbill::Plugin::ActiveMerchant::Utils::KBWiredumpDevice.new(logger)
28
+ io.sync = true
29
+ io.sync.should be_true
30
+ io << 'This is an I/O test'
31
+
32
+ jlogger = ::Killbill::Plugin::KillbillLogger.new(logger)
33
+ jio = ::Killbill::Plugin::ActiveMerchant::Utils::KBWiredumpDevice.new(jlogger)
34
+ jio.sync = true
35
+ jio.sync.should be_true
36
+ jio << 'This is an I/O test (via Java)'
37
+ end
38
+
23
39
  it 'should implement a thread-safe LRU cache' do
24
40
  require 'benchmark'
25
41
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.10
4
+ version: 3.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-19 00:00:00.000000000 Z
11
+ date: 2014-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -256,6 +256,7 @@ files:
256
256
  - lib/killbill/creator.rb
257
257
  - lib/killbill/currency.rb
258
258
  - lib/killbill/ext/active_merchant/jdbc_connection.rb
259
+ - lib/killbill/ext/active_merchant/proxy_support.rb
259
260
  - lib/killbill/ext/active_merchant/typhoeus_connection.rb
260
261
  - lib/killbill/gen/api/account.rb
261
262
  - lib/killbill/gen/api/account_api_exception.rb