grumlin 1.0.0.rc7 → 1.0.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: cf656a485be79f0ce06a1a091d3fb5421712ef05251150ff02ff5d12d867c777
4
- data.tar.gz: 4ad9b95cfc61a9c41cdd0cb43ddd7ecc6686a1797a1162709b1c86cf512fb820
3
+ metadata.gz: 3d77c67f0dc99de145a48c9699f83c02c7f1689011c20a4fce35003ee0c3eb1a
4
+ data.tar.gz: beb9f37e27a057dad388ec74b5c0280ba1f560ddbf6d23251e5c8de997050692
5
5
  SHA512:
6
- metadata.gz: '091041ce7819097c45dbf14c8ed50a3dc620f9a4be929d615934e0f131ed49f1684ecc3bdaf281f77a018c7c4db71e79e8fdb55039f447089e5700f6d5214edb'
7
- data.tar.gz: 00067b1313025fb03bbbf336b5a7258a1ce7de33ab4756f697c916ee7610c54c8a8e28b804af2acf4c766a5de9e4e1188ecea13ba4af7a6b96cf34fcad1884f8
6
+ metadata.gz: 3143048e1834d41ee788f5782aa17f5c7f577de15c71ee82889b02401066632145fa96789a36f1937dcb590a06cbbac6e009fc1034c2d03abf6e93fcb730c685
7
+ data.tar.gz: 07add684f8f072c807c2b0db71ea9292655cabd40400fb4c2ee36089ea9626fcb7b041b2da44866e811e49b4b2495201c810dbaf067727687b0a5ea41e726171
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (1.0.0.rc7)
4
+ grumlin (1.0.0)
5
5
  async-pool (~> 0.3.0)
6
6
  async-websocket (~> 0.22.0)
7
7
  ibsciss-middleware (~> 0.4.0)
@@ -98,7 +98,7 @@ GEM
98
98
  protocol-http (~> 0.2)
99
99
  protocol-http1 (~> 0.2)
100
100
  racc (1.6.0)
101
- rack (3.0.0)
101
+ rack (3.0.1)
102
102
  rainbow (3.1.1)
103
103
  rake (13.0.6)
104
104
  regexp_parser (2.6.0)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Grumlin
2
2
 
3
- [![Ruby](https://github.com/zhulik/grumlin/actions/workflows/main.yml/badge.svg)](https://github.com/zhulik/grumlin/actions/workflows/main.yml)
3
+ [![Ruby](https://github.com/babbel/grumlin/actions/workflows/main.yml/badge.svg)](https://github.com/babbel/grumlin/actions/workflows/main.yml)
4
4
  [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
5
5
  [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)
6
6
 
@@ -286,6 +286,54 @@ end # commits automatically
286
286
 
287
287
  Please check out [bin/console](bin/console) for inspiration. A similar trick may be applied to PRY.
288
288
 
289
+ Then you need to reference it in your application.rb:
290
+ ```ruby
291
+ config.console = MyRailsConsole
292
+ ```
293
+
294
+ #### Testing
295
+
296
+ Grumlin provides a couple of helpers to simplify testing code written with it.
297
+
298
+ ##### RSpec
299
+
300
+ Make sure you have [async-rspec](https://github.com/socketry/async-rspec) installed.
301
+
302
+ `spec_helper.rb` or `rails_helper.rb`:
303
+ ```ruby
304
+ require 'async/rspec'
305
+ require require "grumlin/test/rspec"
306
+ ...
307
+ config.include_context(Async::RSpec::Reactor) # Runs async reactor
308
+ config.include_context(Grumlin::Test::RSpec::GremlinContext) # Injects `g`, `__` and expressions, makes sure client is closed after every test
309
+ config.include_context(Grumlin::Test::RSpec::DBCleanerContext) # Cleans the database before every test
310
+ ...
311
+ ```
312
+
313
+ It is highly recommended to use `Grumlin::Repository` and not trying to use lower level APIs as they are subject to
314
+ change.
315
+
316
+ #### Using in a web app
317
+
318
+ As previously mentioned, `Grumlin` is built on top of the [async stack](https://github.com/socketry/async).
319
+ This basically means you'd either have to use [Falcon](https://github.com/socketry/falcon) as you application server,
320
+ or you'd need to wrap every place where you use `Grumlin` into an `Async` block:
321
+
322
+ ```ruby
323
+ Async do
324
+ MyGrumlinRepository.some_query
325
+ ensure
326
+ Grumlin.close
327
+ end
328
+ ```
329
+
330
+ `Falcon` is preferred because it can keep connections to your Gremlin server open between requests. The only downside
331
+ is that `ActiveRecord` currently does not play well with ruby's fiber scheduler so far, and it can block the event loop.
332
+ When using `Falcon` you don't need explicit `Async` blocks.
333
+
334
+ Currently it's not recommended to use `ActiveRecord` with `Falcon`. If you still need access to a SQL database from your app,
335
+ consider using [socketry/db](https://github.com/socketry/db)
336
+
289
337
  #### Rails console
290
338
 
291
339
  In order to make it possible to execute gremlin queries from the rails console you need to define
@@ -325,32 +373,13 @@ class Async::RailsConsole
325
373
  end
326
374
  ```
327
375
 
328
- Then you need to reference it in your application.rb:
329
- ```ruby
330
- config.console = MyRailsConsole
331
- ```
376
+ #### AWS Neptune
332
377
 
333
- #### Testing
378
+ See [docs/neptune.md](./docs/neptune.md)
334
379
 
335
- Grumlin provides a couple of helpers to simplify testing code written with it.
380
+ #### Sidekiq
336
381
 
337
- ##### RSpec
338
-
339
- Make sure you have [async-rspec](https://github.com/socketry/async-rspec) installed.
340
-
341
- `spec_helper.rb` or `rails_helper.rb`:
342
- ```ruby
343
- require 'async/rspec'
344
- require require "grumlin/test/rspec"
345
- ...
346
- config.include_context(Async::RSpec::Reactor) # Runs async reactor
347
- config.include_context(Grumlin::Test::RSpec::GremlinContext) # Injects `g`, `__` and expressions, makes sure client is closed after every test
348
- config.include_context(Grumlin::Test::RSpec::DBCleanerContext) # Cleans the database before every test
349
- ...
350
- ```
351
-
352
- It is highly recommended to use `Grumlin::Repository` and not trying to use lower level APIs as they are subject to
353
- change.
382
+ See [docs/neptune.md](./docs/sidekiq.md)
354
383
 
355
384
  ## Development
356
385
 
@@ -372,9 +401,9 @@ and run `rake definitions:format`. You don't need to properly sort the lists man
372
401
 
373
402
  ## Contributing
374
403
 
375
- Bug reports and pull requests are welcome on GitHub at https://github.com/zhulik/grumlin. This project is intended to
404
+ Bug reports and pull requests are welcome on GitHub at https://github.com/babbel/grumlin. This project is intended to
376
405
  be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
377
- [code of conduct](https://github.com/zhulik/grumlin/blob/master/CODE_OF_CONDUCT.md).
406
+ [code of conduct](https://github.com/babbel/grumlin/blob/master/CODE_OF_CONDUCT.md).
378
407
 
379
408
  ## License
380
409
 
data/docs/neptune.md ADDED
@@ -0,0 +1,65 @@
1
+ # AWS Neptune
2
+
3
+ Using AWS neptune with IAM authentication enabled requires some additional configuration. You'd need
4
+ to provide `Grumlin` with a customized `Grumlin::Client` that is aware of authentication:
5
+ ```ruby
6
+ # authenticated_client.rb
7
+
8
+ class AuthenticatedClient < Grumlin::Client
9
+ SERVICE = "neptune-db"
10
+ METHOD = "GET"
11
+
12
+ def initialize(url, region:, parent: Async::Task.current)
13
+ @url = url
14
+ @region = region
15
+ super(@url, parent:)
16
+ end
17
+
18
+ def write(*, **)
19
+ connect unless connected?
20
+ super
21
+ end
22
+
23
+ private
24
+
25
+ def signer
26
+ @signer ||= Aws::Sigv4::Signer.new(service: SERVICE,
27
+ region: @region,
28
+ credentials_provider:,
29
+ apply_checksum_header: false)
30
+ end
31
+
32
+ def credentials_provider
33
+ @credentials_provider ||= Aws::CredentialProviderChain.new.resolve
34
+ end
35
+
36
+ def signed_headers
37
+ signer.sign_request(
38
+ http_method: METHOD,
39
+ url: @url
40
+ ).headers.except("host")
41
+ end
42
+
43
+ # Override
44
+ def build_transport
45
+ Grumlin::Transport.new(@url, parent: @parent, headers: signed_headers)
46
+ end
47
+ end
48
+ ```
49
+
50
+
51
+ ```ruby
52
+ # config/initializers/grumlin.rb
53
+
54
+ Grumlin.configure do |config|
55
+ config.url = ENV.fetch("GREMLIN_URL")
56
+
57
+ if ENV.fetch("GREMLIN_USE_IAM")
58
+ config.provider = :neptune if ENV.fetch("NEPTUNE_REGION") != "local"
59
+
60
+ config.client_factory = lambda do |url, parent|
61
+ AuthenticatedClient.new(url, region: ENV.fetch("NEPTUNE_REGION"), parent:)
62
+ end
63
+ end
64
+ end
65
+ ```
data/docs/sidekiq.md ADDED
@@ -0,0 +1,47 @@
1
+ # Sidekiq
2
+
3
+ Sidekiq does not use event loop, so you'd have to use explicit `Async` blocks:
4
+
5
+ ```ruby
6
+ class MyWorker
7
+ include Sidekiq::Worker
8
+
9
+ def perform
10
+ Async do
11
+ MyGrumlinRepository.some_query
12
+ ensure
13
+ Grumlin.close
14
+ end
15
+ end
16
+ end
17
+ ```
18
+
19
+ As the other option you can use a server middleware:
20
+
21
+ ```ruby
22
+ # async_server_middleware.rb
23
+
24
+ class AsyncServerMiddleware
25
+ def call(_worker, _job, _queue)
26
+ Async do
27
+ yield
28
+ ensure
29
+ Grumlin.close
30
+ end
31
+ end
32
+ end
33
+ ```
34
+
35
+ ```ruby
36
+ # config/initializers/sidekiq.rb
37
+
38
+ Sidekiq.configure_server do |config|
39
+ config.server_middleware do |chain|
40
+ chain.add AsyncServerMiddleware
41
+ end
42
+
43
+ config.on(:shutdown) do
44
+ Grumlin.close
45
+ end
46
+ end
47
+ ```
data/grumlin.gemspec CHANGED
@@ -14,12 +14,12 @@ Gem::Specification.new do |spec|
14
14
  Gremlin graph traversal language DSL and client for Ruby. Suitable and tested with gremlin-server and AWS Neptune.
15
15
  DESCRIPTION
16
16
 
17
- spec.homepage = "https://github.com/zhulik/grumlin"
17
+ spec.homepage = "https://github.com/babbel/grumlin"
18
18
  spec.license = "MIT"
19
19
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
20
20
 
21
21
  spec.metadata["homepage_uri"] = spec.homepage
22
- spec.metadata["source_code_uri"] = "https://github.com/zhulik/grumlin"
22
+ spec.metadata["source_code_uri"] = "https://github.com/babbel/grumlin"
23
23
  spec.metadata["changelog_uri"] = "https://github.com/babbel/grumlin/releases"
24
24
  spec.metadata["rubygems_mfa_required"] = "true"
25
25
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- VERSION = "1.0.0.rc7"
4
+ VERSION = "1.0.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grumlin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Sinyavskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-10 00:00:00.000000000 Z
11
+ date: 2022-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-pool
@@ -120,6 +120,8 @@ files:
120
120
  - bin/setup
121
121
  - doc/middlewares.md
122
122
  - docker-compose.yml
123
+ - docs/neptune.md
124
+ - docs/sidekiq.md
123
125
  - gremlin_server/Dockerfile
124
126
  - gremlin_server/tinkergraph-empty.properties
125
127
  - gremlin_server/tinkergraph-gremlin/lib/tinkergraph-gremlin-3.5.3.jar
@@ -196,12 +198,12 @@ files:
196
198
  - lib/grumlin/vertex_property.rb
197
199
  - lib/grumlin/with_extension.rb
198
200
  - lib/tasks/benchmark.rake
199
- homepage: https://github.com/zhulik/grumlin
201
+ homepage: https://github.com/babbel/grumlin
200
202
  licenses:
201
203
  - MIT
202
204
  metadata:
203
- homepage_uri: https://github.com/zhulik/grumlin
204
- source_code_uri: https://github.com/zhulik/grumlin
205
+ homepage_uri: https://github.com/babbel/grumlin
206
+ source_code_uri: https://github.com/babbel/grumlin
205
207
  changelog_uri: https://github.com/babbel/grumlin/releases
206
208
  rubygems_mfa_required: 'true'
207
209
  post_install_message:
@@ -215,9 +217,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
217
  version: 2.7.0
216
218
  required_rubygems_version: !ruby/object:Gem::Requirement
217
219
  requirements:
218
- - - ">"
220
+ - - ">="
219
221
  - !ruby/object:Gem::Version
220
- version: 1.3.1
222
+ version: '0'
221
223
  requirements: []
222
224
  rubygems_version: 3.2.33
223
225
  signing_key: