Navigation Menu

Skip to content

Commit

Permalink
Dispose client for the soruce node
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 14, 2015
1 parent 7817978 commit 5d69181
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/droonga/plugins/system/absorb_data.rb
Expand Up @@ -233,13 +233,15 @@ def source_client_options
}
end

def source_client
@source_client ||= Droonga::Client.new(source_client_options)
def create_source_client
Droonga::Client.new(source_client_options)
end

def get_source_tables(&block)
source_client.request("dataset" => source_dataset,
"type" => "table_list") do |response|
client = create_source_client
client.request("dataset" => source_dataset,
"type" => "table_list") do |response|
client.close
unless response
raise EmptyResponse.new("table_list returns nil response")
end
Expand Down Expand Up @@ -268,12 +270,14 @@ def get_total_n_source_records(&block)
},
}
end
source_client.request("dataset" => source_dataset,
"type" => "search",
"body" => {
"timeout" => 10,
"queries" => queries,
}) do |response|
client = create_source_client
client.request("dataset" => source_dataset,
"type" => "search",
"body" => {
"timeout" => 10,
"queries" => queries,
}) do |response|
client.close
unless response
raise EmptyResponse.new("search returns nil response")
end
Expand Down

0 comments on commit 5d69181

Please sign in to comment.