lib/grumlin/client.rb in grumlin-0.22.5 vs lib/grumlin/client.rb in grumlin-0.23.0
- old
+ new
@@ -22,12 +22,12 @@
def close
@client.close
end
- def write(bytecode, session_id: nil)
- @client.write(bytecode, session_id: session_id)
+ def write(query)
+ @client.write(query)
ensure
@count += 1
end
def viable?
@@ -92,19 +92,17 @@
def connected?
@transport&.connected? || false
end
# TODO: support yielding
- def write(bytecode, session_id: nil)
+ def write(query)
raise NotConnectedError unless connected?
- request = to_query(bytecode, session_id: session_id)
-
- channel = @request_dispatcher.add_request(request)
+ channel = @request_dispatcher.add_request(query)
begin
- @transport.write(request)
- channel.dequeue.flat_map { |item| Typing.cast(item) }
+ @transport.write(query)
+ channel.dequeue
rescue Async::Stop, Async::TimeoutError
close(check_requests: false)
raise
end
end
@@ -120,24 +118,8 @@
private
# This might be overridden in successors
def build_transport
Transport.new(@url, parent: @parent, **@client_options)
- end
-
- def to_query(bytecode, session_id:)
- {
- requestId: SecureRandom.uuid,
- op: :bytecode,
- processor: session_id ? :session : :traversal,
- args: {
- gremlin: {
- :@type => "g:Bytecode",
- :@value => bytecode.serialize
- },
- aliases: { g: :g },
- session: session_id
- }.compact
- }
end
end
end