7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/cql/client/request_runner.rb', line 7
def execute(connection, request, timeout=nil)
connection.send_request(request, timeout).map do |response|
case response
when Protocol::RowsResultResponse
QueryResult.new(response.metadata, response.rows)
when Protocol::ErrorResponse
cql = request.is_a?(Protocol::QueryRequest) ? request.cql : nil
raise QueryError.new(response.code, response.message, cql)
when Protocol::SetKeyspaceResultResponse
KeyspaceChanged.new(response.keyspace)
when Protocol::AuthenticateResponse
AuthenticationRequired.new(response.authentication_class)
else
if block_given?
yield response
else
nil
end
end
end
end
|