Class: Graphd::Client
- Inherits:
-
Object
- Object
- Graphd::Client
- Defined in:
- lib/graphd/client.rb
Overview
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)
Instance Method Summary collapse
- #alter(operation) ⇒ Object
-
#check_version ⇒ String
Get the version of the DGraph server.
- #client ⇒ Object
-
#initialize(*clients) ⇒ Client
constructor
Create a new instance of Graphd::Client.
-
#txn(read_only: false, best_effort: false) ⇒ Transaction
Create a new transaction.
Constructor Details
#initialize(*clients) ⇒ Client
Create a new instance of Graphd::Client
17 18 19 20 21 22 |
# File 'lib/graphd/client.rb', line 17 def initialize(*clients) raise ClientError unless clients @clients = clients @jwt = Api::Jwt.new end |
Instance Method Details
#alter(operation) ⇒ Object
33 34 35 |
# File 'lib/graphd/client.rb', line 33 def alter(operation) client.alter(operation) end |
#check_version ⇒ String
Get the version of the DGraph server
27 28 29 30 31 |
# File 'lib/graphd/client.rb', line 27 def check_version request = Api::Check.new response = client.check_version(request) response.tag end |
#client ⇒ Object
47 48 49 |
# File 'lib/graphd/client.rb', line 47 def client @clients.sample end |
#txn(read_only: false, best_effort: false) ⇒ Transaction
Create a new transaction
43 44 45 |
# 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 |