diff options
| author | Robert | 2017-08-21 20:24:50 +0200 |
|---|---|---|
| committer | Robert | 2017-08-22 09:37:30 +0200 |
| commit | 61c4a303183284fc107325aeeef5ace7a3e68c0c (patch) | |
| tree | 71bbfe5e5fe9eddb9e381aa0536b44476f461bc1 /app/workers | |
| parent | 327b1ec771a056451b0635ba80cc346fa1765299 (diff) | |
| download | chouette-core-61c4a303183284fc107325aeeef5ace7a3e68c0c.tar.bz2 | |
Refs: #4273@3h;
Debugging Java Integration (ZipService -> HTTPService -> Object Creation)
- Created an ErrorFormat concern to see what went wrong in the HTTP call
as so many things can go wrong due to:
* Timeout Issues
* Illegal database setup or cleaning before tests
Diffstat (limited to 'app/workers')
| -rw-r--r-- | app/workers/workbench_import_worker.rb | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/app/workers/workbench_import_worker.rb b/app/workers/workbench_import_worker.rb index f91093806..d06d4607c 100644 --- a/app/workers/workbench_import_worker.rb +++ b/app/workers/workbench_import_worker.rb @@ -31,23 +31,17 @@ class WorkbenchImportWorker host: export_host, path: export_path, token: token(eg_name), - params: params, - upload: {file: [eg_file, 'application/zip', eg_name]}) + params: params(eg_file, eg_name)) end def log_failure reason, count logger.warn "HTTP POST failed with #{reason}, count = #{count}, response=#{@response}" end - def try_again - raise RetryService::Retry - end - def try_upload_entry_group eg_name, eg_file result = execute_post eg_name, eg_file - return result if result && result.status < 400 - @response = result.body - try_again + return Result.ok(result) if result && result.status < 400 + Result.error(JSON.parse result.body) end def upload zip_service @@ -63,6 +57,7 @@ class WorkbenchImportWorker retry_service = RetryService.new( delays: RETRY_DELAYS, rescue_from: [HTTPService::Timeout], + logger: logger, &method(:log_failure)) status = retry_service.execute(&upload_entry_group_proc(entry_pair)) raise StopIteration unless status.ok? @@ -116,7 +111,11 @@ class WorkbenchImportWorker @__import_url__ ||= File.join(import_host, import_path) end - def params - @__params__ ||= { netex_import: { referential_id: @workbench_import.referential_id, workbench_id: @workbench_import.workbench_id } } + def params file, name + { netex_import: + { referential_id: @workbench_import.referential_id, + workbench_id: @workbench_import.workbench_id, + name: name, + file: HTTPService.upload(file, 'application/zip', name) } } end end |
