Sha256: 17a7eee6e7f9e0ab72b51da670a1bcd83bb7a3aa79e0547b1ea1d31af9d7a459
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
require 'xmlrpc/client' module OpenX class XmlrpcClient EXCEPTION_CLASSES = [ ::Timeout::Error, ::Errno::EINVAL, ::Errno::EPIPE, ::Errno::ECONNRESET, ::EOFError, ::Net::HTTPBadResponse, ::Net::HTTPHeaderSyntaxError, ::Net::ProtocolError ].freeze attr_reader :client, :url def initialize(url) @url = url @retries = 0 init_client! end def call(method, *args) @client.call(method, *(convert(args))) rescue *EXCEPTION_CLASSES => e cycle = (cycle || 0) + 1 raise(e) if cycle > 10 || OpenX.configuration['retry'] == false init_client! retry end protected def convert(args) args end private def init_client! @client = XMLRPC::Client.new2(url) @client.timeout = OpenX.configuration['timeout'] end end class XmlrpcSessionClient < XmlrpcClient attr_reader :session def initialize(session) @session = session super(session.url) end def call(method, *args) super rescue XMLRPC::FaultException => e cycle = (cycle || 0) + 1 raise(e) if cycle > 10 || e.message !~ /Session ID.*invalid/i session.recreate! retry end protected def convert(args) [session.id] + args end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
krakatoa-openx-1.9.4 | lib/openx/xmlrpc_client.rb |
bsm-openx-1.9.4 | lib/openx/xmlrpc_client.rb |
bsm-openx-1.9.3 | lib/openx/xmlrpc_client.rb |