graphd 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2d4e121c4e6a3a5150912b20ae0bca19a48d2e9de535c965615a7d5558bb770
4
- data.tar.gz: e4af93a38448a47796d19c54a50adf9921222f0dc2c4dbbd18882270bae74924
3
+ metadata.gz: 88eb11e1213f9fec8d7a0878d7843fe27c964d1bf58411723a786d05336030dd
4
+ data.tar.gz: 615be59bdd018561230ef2a94d03b1621944ff8795c35d24b22fa622104097d5
5
5
  SHA512:
6
- metadata.gz: f3d9a2613043742932f0fc4e50253c9ca82f55611af86a0556a5168ffcb4e7be1c7122c3bce3c9eb6e14c8695c0650fb2f290db951e3cda1517a96a8dc5750fe
7
- data.tar.gz: 2afdaca018157f54aa5851371257582231574ccd82f6315cd7f8129b9c46ae54c2f9a8f01c6350c4a3508c4326681b2c1d05577e7c3343cc30794aa79add5b8b
6
+ metadata.gz: f11e994643bb475fcc61edd2cac76d8e93fbe34cf654e27652e16beb9222af284ae2923d9ae35c80c7c3d1c647bedfcb30ddd00a37f6c4c771b133df45e5f1c2
7
+ data.tar.gz: eeb3ed744e29ec79eb081a8c323d90ce066fc754800f8afa894daf31397580454826a883fa74850def50df7885fa325765f9e89189e3acc1951bfa05bafc9cd5
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
  .byebug_history
13
+ *.gem
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # Graphd
2
+ [![Gem Version](https://badge.fury.io/rb/graphd.svg)](https://badge.fury.io/rb/graphd)
3
+
2
4
  A Ruby client for [DGraph](https://github.com/dgraph-io/dgraph) that uses [gRPC](https://grpc.io/).
3
5
 
4
6
  This client follows [pydgraph](https://github.com/dgraph-io/pydgraph) closely.
@@ -21,6 +23,9 @@ Or install it yourself as:
21
23
 
22
24
  $ gem install graphd
23
25
 
26
+ ## Usage
27
+ The `simple_example.rb` script in `examples` demonstrates usage and currently available features.
28
+
24
29
  ## Contributing
25
30
 
26
31
  Bug reports and pull requests are welcome on GitHub at https://github.com/thegeorgeous/graphd. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/thegeorgeous/graphd/blob/master/CODE_OF_CONDUCT.md).
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
17
17
 
18
18
  spec.metadata['homepage_uri'] = spec.homepage
19
- spec.metadata['source_code_uri'] = 'https://rubygems.org/graphd'
19
+ spec.metadata['source_code_uri'] = 'https://github.com/thegeorgeous/graphd'
20
20
  spec.metadata['changelog_uri'] = 'https://github.com/thegeorgeous/graphd'
21
21
 
22
22
  # Specify which files should be added to the gem when it is released.
@@ -27,4 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.bindir = 'bin'
28
28
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ['lib']
30
+
31
+ spec.add_runtime_dependency 'grpc', '~> 1.34.0'
30
32
  end
@@ -27,8 +27,8 @@ module Graphd
27
27
  client.alter(operation)
28
28
  end
29
29
 
30
- def txn(read_only: false)
31
- Transaction.new(self, read_only: read_only)
30
+ def txn(read_only: false, best_effort: false)
31
+ Transaction.new(self, read_only: read_only, best_effort: best_effort)
32
32
  end
33
33
 
34
34
  def client
@@ -4,13 +4,18 @@ require 'json'
4
4
 
5
5
  module Graphd
6
6
  class Transaction
7
- def initialize(client, read_only: false)
7
+ def initialize(client, read_only: false, best_effort: false)
8
+ if !read_only && best_effort
9
+ raise TransactionError, 'Best effort transactions are only compatible with read-only transactions'
10
+ end
11
+
8
12
  @client = client
9
13
  @client_stub = @client.client
10
14
  @transaction_context = ::Api::TxnContext.new
11
15
  @finished = false
12
16
  @mutated = false
13
17
  @read_only = read_only
18
+ @best_effort = best_effort
14
19
  end
15
20
 
16
21
  def mutate(mutation: nil, set_obj: nil, del_obj: nil, commit_now: nil)
@@ -38,9 +43,14 @@ module Graphd
38
43
  end
39
44
 
40
45
  def create_request(query: nil, variables: nil, mutations: nil, commit_now: nil)
41
- request = ::Api::Request.new(start_ts: @transaction_context.start_ts, commit_now: commit_now)
46
+ request = ::Api::Request.new(
47
+ start_ts: @transaction_context.start_ts,
48
+ commit_now: commit_now,
49
+ read_only: true,
50
+ best_effort: true
51
+ )
42
52
  variables&.each do |key, value|
43
- if key.is_a?(String) && value.is_a?(String)
53
+ unless key.is_a?(String) && value.is_a?(String)
44
54
  raise TransactionError, 'Values and keys in variable map must be strings'
45
55
  end
46
56
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Graphd
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Thomas
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2020-12-27 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: grpc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.34.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.34.0
13
27
  description:
14
28
  email:
15
29
  - iamgeorgethomas@gmail.com
@@ -51,7 +65,7 @@ licenses:
51
65
  metadata:
52
66
  allowed_push_host: https://rubygems.org
53
67
  homepage_uri: https://github.com/thegeorgeous/graphd
54
- source_code_uri: https://rubygems.org/graphd
68
+ source_code_uri: https://github.com/thegeorgeous/graphd
55
69
  changelog_uri: https://github.com/thegeorgeous/graphd
56
70
  post_install_message:
57
71
  rdoc_options: []