Skip to content

Commit

Permalink
Remove support for ruby 3.0, update deps, fix logging using Console, …
Browse files Browse the repository at this point in the history
…rubocop autocorrect (#143)

* Remove support for ruby 3.0, update deps, fix logging using Console
  • Loading branch information
zhulik authored May 16, 2024
1 parent b92ed98 commit 3cd70b4
Show file tree
Hide file tree
Showing 34 changed files with 103 additions and 101 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0"
bundler-cache: true

- name: Run rubocop
Expand All @@ -20,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: ["3.0", "3.1", "3.2", "3.3"]
ruby: ["3.1", "3.2", "3.3"]
steps:
- uses: actions/checkout@v2

Expand Down Expand Up @@ -53,7 +52,6 @@ jobs:

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0"
bundler-cache: true

- name: Build gem
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 3.0
TargetRubyVersion: 3.1
NewCops: enable
SuggestExtensions: false

Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby 3.0.6
ruby 3.1.5
68 changes: 39 additions & 29 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
PATH
remote: .
specs:
grumlin (1.2.0)
async-pool (~> 0.4.0)
grumlin (1.3.0)
async (~> 2.11.0)
async-http (~> 0.66.0)
async-io (~> 1.43.0)
async-pool (~> 0.6.0)
async-websocket (~> 0.26.0)
console (~> 1.25.0)
ibsciss-middleware (~> 0.4.0)
oj (~> 3.16.0)
retryable (~> 3.0.0)
Expand All @@ -23,30 +27,31 @@ GEM
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
async (1.31.0)
console (~> 1.10)
nio4r (~> 2.3)
async (2.11.0)
console (~> 1.25, >= 1.25.2)
fiber-annotation
io-event (~> 1.5, >= 1.5.1)
timers (~> 4.1)
async-http (0.61.0)
async (>= 1.25)
async-io (>= 1.28)
async-pool (>= 0.2)
protocol-http (~> 0.25.0)
protocol-http1 (~> 0.16.0)
protocol-http2 (~> 0.15.0)
async-http (0.66.3)
async (>= 2.10.2)
async-pool (>= 0.6.1)
io-endpoint (~> 0.10, >= 0.10.3)
io-stream (~> 0.4)
protocol-http (~> 0.26.0)
protocol-http1 (~> 0.19.0)
protocol-http2 (~> 0.17.0)
traces (>= 0.10.0)
async-io (1.38.1)
async-io (1.43.2)
async
async-pool (0.4.0)
async-pool (0.6.1)
async (>= 1.25)
async-rspec (1.17.0)
rspec (~> 3.0)
rspec-files (~> 1.0)
rspec-memory (~> 1.0)
async-websocket (0.26.0)
async-websocket (0.26.1)
async-http (~> 0.54)
async-io (~> 1.23)
protocol-rack (~> 0.1)
protocol-rack (~> 0.5)
protocol-websocket (~> 0.11)
backport (1.2.0)
base64 (0.2.0)
Expand All @@ -56,9 +61,10 @@ GEM
childprocess (4.1.0)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
console (1.23.3)
console (1.25.2)
fiber-annotation
fiber-local
fiber-local (~> 1.1)
json
dead_end (4.0.0)
diff-lcs (1.5.0)
docile (1.4.0)
Expand All @@ -68,11 +74,16 @@ GEM
factory_bot (6.4.5)
activesupport (>= 5.0.0)
fiber-annotation (0.2.0)
fiber-local (1.0.0)
fiber-local (1.1.0)
fiber-storage
fiber-storage (0.1.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
ibsciss-middleware (0.4.2)
ibsciss-middleware (0.4.3)
iniparse (1.5.0)
io-endpoint (0.10.3)
io-event (1.5.1)
io-stream (0.4.0)
jaro_winkler (1.5.6)
json (2.7.1)
kramdown (2.4.0)
Expand All @@ -84,7 +95,6 @@ GEM
mini_portile2 (2.8.5)
minitest (5.20.0)
mutex_m (0.2.0)
nio4r (2.7.0)
nokogiri (1.16.0)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
Expand All @@ -100,20 +110,20 @@ GEM
parser (3.2.2.4)
ast (~> 2.4.1)
racc
protocol-hpack (1.4.2)
protocol-http (0.25.0)
protocol-http1 (0.16.1)
protocol-hpack (1.4.3)
protocol-http (0.26.5)
protocol-http1 (0.19.1)
protocol-http (~> 0.22)
protocol-http2 (0.15.1)
protocol-http2 (0.17.0)
protocol-hpack (~> 1.4)
protocol-http (~> 0.18)
protocol-rack (0.4.1)
protocol-rack (0.5.1)
protocol-http (~> 0.23)
rack (>= 1.0)
protocol-websocket (0.12.1)
protocol-http (~> 0.2)
racc (1.7.3)
rack (3.0.8)
rack (3.0.11)
rainbow (3.1.1)
rake (13.1.0)
rbs (2.8.4)
Expand Down Expand Up @@ -196,7 +206,7 @@ GEM
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
yard (0.9.34)
zeitwerk (2.6.12)
zeitwerk (2.6.14)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ event loop.

## Dependencies

Grumlin works with ruby >= 3.0, but it's recommended to use 3.1 due to [zlib warnings](https:/socketry/async-websocket/issues/42).
Grumlin works with ruby >= 3.1.

## Install

Expand Down
8 changes: 6 additions & 2 deletions grumlin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |spec|

spec.homepage = "https:/babbel/grumlin"
spec.license = "MIT"
spec.required_ruby_version = Gem::Requirement.new(">= 3.0")
spec.required_ruby_version = Gem::Requirement.new(">= 3.1")

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https:/babbel/grumlin"
Expand All @@ -28,8 +28,12 @@ Gem::Specification.new do |spec|
end
spec.require_paths = ["lib"]

spec.add_dependency "async-pool", "~> 0.4.0"
spec.add_dependency "async", "~> 2.11.0"
spec.add_dependency "async-http", "~> 0.66.0"
spec.add_dependency "async-io", "~> 1.43.0"
spec.add_dependency "async-pool", "~> 0.6.0"
spec.add_dependency "async-websocket", "~> 0.26.0"
spec.add_dependency "console", "~> 1.25.0"
spec.add_dependency "ibsciss-middleware", "~> 0.4.0"
spec.add_dependency "oj", "~> 3.16.0"
spec.add_dependency "retryable", "~> 3.0.0"
Expand Down
6 changes: 2 additions & 4 deletions lib/grumlin/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ def reusable?
end
end

include Console

# Client is not reusable. Once closed should be recreated.
def initialize(url, parent: Async::Task.current, **client_options)
@url = url
Expand All @@ -62,7 +60,7 @@ def connect
rescue Async::Stop, Async::TimeoutError, StandardError
close(check_requests: false)
end
logger.debug(self, "Connected")
Console.debug(self, "Connected")
end

# Before calling close the user must ensure that:
Expand All @@ -85,7 +83,7 @@ def close(check_requests: true) # rubocop:disable Metrics/CyclomaticComplexity,M

raise Grumlin::ResourceLeakError, "Request list is not empty: #{@request_dispatcher.requests}" if check_requests
ensure
logger.debug(self, "Closed")
Console.debug(self, "Closed")
end

def connected?
Expand Down
2 changes: 1 addition & 1 deletion lib/grumlin/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def initialize
@pool_size = 10
@client_concurrency = 5
@provider = :tinkergraph
@client_factory = ->(url, parent) { Grumlin::Client.new(url, parent: parent) }
@client_factory = ->(url, parent) { Grumlin::Client.new(url, parent:) }
end

def middlewares
Expand Down
4 changes: 1 addition & 3 deletions lib/grumlin/dummy_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
class Grumlin::DummyTransaction < Grumlin::Transaction
attr_reader :uuid

include Console

def initialize(traversal_start_class, middlewares:, pool:)
super
@session_id = nil

logger.info(self) do
Console.info(self) do
"#{Grumlin.config.provider} does not support transactions. commit and rollback are ignored, data will be saved"
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/grumlin/repository/error_handling_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def retry?
@mode == :retry
end

def apply!(&block)
def apply!(&)
return yield if raise?
return ignore_errors!(&block) if ignore?
return ignore_errors!(&) if ignore?

retry_errors!(&block)
retry_errors!(&)
end

private
Expand All @@ -34,7 +34,7 @@ def ignore_errors!
# ignore errors
end

def retry_errors!(&block)
Retryable.retryable(**@params, &block)
def retry_errors!(&)
Retryable.retryable(**@params, &)
end
end
10 changes: 5 additions & 5 deletions lib/grumlin/repository/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def drop_in_batches(traversal, batch_size: 10_000) # rubocop:disable Metrics/Abc

return if traversal.count.next.zero?

drop_in_batches(traversal, batch_size: batch_size)
drop_in_batches(traversal, batch_size:)

Console.logger.info(self) { "drop_in_batches: finished." }
end
Expand Down Expand Up @@ -123,17 +123,17 @@ def upsert_edges(edges, batch_size: 100, on_failure: :retry, start: g, **params)

private

def with_upsert_error_handling(on_failure, params, &block)
def with_upsert_error_handling(on_failure, params, &)
if params.any?
Grumlin::Repository::ErrorHandlingStrategy.new(mode: on_failure, **UPSERT_RETRY_PARAMS.merge(params))
else
DEFAULT_ERROR_HANDLING_STRATEGY
end.apply!(&block)
end.apply!(&)
end

def with_upsert_retry(retry_params, &block)
def with_upsert_retry(retry_params, &)
retry_params = UPSERT_RETRY_PARAMS.merge(retry_params)
Retryable.retryable(**retry_params, &block)
Retryable.retryable(**retry_params, &)
end

def cleanup_properties(create_properties, update_properties, *props_to_cleanup)
Expand Down
2 changes: 1 addition & 1 deletion lib/grumlin/request_dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def add_request(request)
raise RequestAlreadyAddedError if @requests.include?(request[:requestId])

Async::Channel.new.tap do |channel|
@requests[request[:requestId]] = { request: request, result: [], channel: channel }
@requests[request[:requestId]] = { request:, result: [], channel: }
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/grumlin/shortcuts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def shortcut(name, shortcut = nil, override: false, lazy: true, &block)

raise ArgumentError, "either shortcut or block must be passed" if [shortcut, block].count(&:nil?) != 1

shortcuts.add(name, shortcut || Grumlin::Shortcut.new(name, lazy: lazy, &block))
shortcuts.add(name, shortcut || Grumlin::Shortcut.new(name, lazy:, &block))
end

def shortcuts_from(other_shortcuts)
Expand Down
4 changes: 2 additions & 2 deletions lib/grumlin/shortcuts/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def add(name, shortcut)
sc = step_class

shortcut_methods_module.define_method(name) do |*args, **params|
next sc.new(name, args: args, params: params, previous_step: self, pool: pool)
next sc.new(name, args:, params:, previous_step: self, pool:)
end
extend_traversal_classes(shortcut) unless shortcut.lazy?
end
Expand All @@ -47,7 +47,7 @@ def add_from(other)
end

def g(middlewares: Grumlin.default_middlewares)
traversal_start_class.new(pool: Grumlin.default_pool, middlewares: middlewares)
traversal_start_class.new(pool: Grumlin.default_pool, middlewares:)
end

def __
Expand Down
2 changes: 1 addition & 1 deletion lib/grumlin/shortcuts_applyer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def process_steps(steps, shortcuts) # rubocop:disable Metrics/AbcSize
args = step.args.map { |arg| call(arg) }

shortcut = shortcuts[step.name]
next result << Grumlin::StepData.new(step.name, args: args, params: step.params) unless shortcut&.lazy?
next result << Grumlin::StepData.new(step.name, args:, params: step.params) unless shortcut&.lazy?

t = shortcuts.__
step = shortcut.apply(t, *args, **step.params)
Expand Down
6 changes: 3 additions & 3 deletions lib/grumlin/step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Grumlin::Step < Grumlin::Steppable
# TODO: replace pool, session_id and middlewares with a context?
def initialize(name, args: [], params: {}, previous_step: nil, pool: nil, session_id: nil, # rubocop:disable Metrics/ParameterLists
middlewares: Grumlin.default_middlewares)
super(pool: pool, session_id: session_id, middlewares: middlewares)
super(pool:, session_id:, middlewares:)

@name = name.to_sym
@args = args # TODO: add recursive validation: only json types or Step
Expand Down Expand Up @@ -55,7 +55,7 @@ def inspect
end

def bytecode(no_return: false)
Grumlin::StepsSerializers::Bytecode.new(steps, no_return: no_return)
Grumlin::StepsSerializers::Bytecode.new(steps, no_return:)
end

def next
Expand Down Expand Up @@ -85,7 +85,7 @@ def iterate

def send_query(need_results:)
@middlewares.call(traversal: self,
need_results: need_results,
need_results:,
session_id: @session_id,
pool: @pool)
end
Expand Down
Loading

0 comments on commit 3cd70b4

Please sign in to comment.