16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/ruby-libstorj/ext/create_bucket_request.rb', line 16
def self.after_work_cb
args = [::LibStorj::Ext::UV::Work.by_ref, :int]
FFI::Function.new :void, args do |work_req_ptr|
req = new work_req_ptr[:data]
response = ::LibStorj::Ext::JsonC.stringify req[:response]
error = ::LibStorj::Ext::Curl.curl_code_to_string req[:error_code]
c_handle = FFI::Function.new :void, %i[string pointer], req[:handle]
next c_handle.call(error, ::FFI::MemoryPointer::NULL) unless error.empty?
status_code, bucket = req.values_at %i[status_code bucket]
if ((status_code > 299) || bucket.id.nil?) && error.empty?
response_error = JSON.parse(response)['error']
error = response_error
next c_handle.call(error, ::FFI::MemoryPointer::NULL)
end
bucket_pointer = req[:bucket]
c_handle.call nil, bucket_pointer
end
end
|