class Graphd::Client
Client
initialized to talk to a DGraph instance Accepts multiple instances of Graphd::ClientStub
Examples: client_stub = Graphd::ClientStub.new
('localhost:9080') client = Graphd::Cilent.new(client_stub)
Public Class Methods
new(*clients)
click to toggle source
Create a new instance of Graphd::Client
@param clients [Array<Graphd::ClientStub>] The stubs that can be used
to communicate with a DGraph server
# File lib/graphd/client.rb, line 17 def initialize(*clients) raise ClientError unless clients @clients = clients @jwt = Api::Jwt.new end
Public Instance Methods
alter(operation)
click to toggle source
# File lib/graphd/client.rb, line 33 def alter(operation) client.alter(operation) end
check_version()
click to toggle source
Get the version of the DGraph server
@return [String] the version of the DGraph server
# File lib/graphd/client.rb, line 27 def check_version request = Api::Check.new response = client.check_version(request) response.tag end
client()
click to toggle source
# File lib/graphd/client.rb, line 47 def client @clients.sample end
txn(read_only: false, best_effort: false)
click to toggle source
Create a new transaction
@param read_only [true, false] whether the transaction should be read only @param best_effort [true, false] Enable best-effort queries for the transaction
@return [Transaction]
# File lib/graphd/client.rb, line 43 def txn(read_only: false, best_effort: false) Transaction.new(self, read_only: read_only, best_effort: best_effort) end