Skip to content

Commit

Permalink
Merge pull request #4 from onlyoffice-testing-robot/feature/add_async…
Browse files Browse the repository at this point in the history
…_convertion

Feature/add async convertation
  • Loading branch information
ShockwaveNN authored Aug 21, 2018
2 parents e690b71 + b566841 commit b5745ab
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change log

## 0.1.1 (2018-08-21)

### Changed

* Add async request sending

## master (unreleased)

### New features
Expand Down
16 changes: 15 additions & 1 deletion lib/onlyoffice_documentserver_conversion_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'jwt'
require 'net/http'
require 'securerandom'
require 'timeout'
require_relative 'onlyoffice_documentserver_conversion_helper/version'

# Stuff for working with conversion service
Expand Down Expand Up @@ -80,7 +81,20 @@ def request(convert_url, params)
http = Net::HTTP.new(uri.host, uri.port)
http.read_timeout = @timeout
http.use_ssl = true if uri.scheme == 'https'
http.request(req).body
send_request(http, req)
end

# sending request every 5 second within @timeout
# responce will contain 504 if
# return responce body
def send_request(http, req)
Timeout.timeout(@timeout) do
(@timeout / 5).times do
responce = http.request(req)
return responce.body unless responce.code == '504'
sleep 5
end
end
end

# @return [Hash] with usl for download file after conversion and response data
Expand Down
2 changes: 1 addition & 1 deletion lib/onlyoffice_documentserver_conversion_helper/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module OnlyofficeDocumentserverConversionHelper
# This module holds the OnlyofficeDocumentserverConversionHelper gem version
module Version
STRING = '0.1.0'.freeze
STRING = '0.1.1'.freeze
end
end

0 comments on commit b5745ab

Please sign in to comment.