Skip to content

Commit

Permalink
Explicit modules (#425)
Browse files Browse the repository at this point in the history
* explicit modules

* changelog update
  • Loading branch information
mensfeld authored Dec 16, 2023
1 parent 082a8b5 commit b5b13c2
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# WaterDrop changelog

## 2.6.12 (Unreleased)
- [Fix] Use explicit file modules declarations to avoid potential loading errors.
- [Change] Remove usage of concurrent ruby.

## 2.6.11 (2023-10-25)
Expand Down
7 changes: 7 additions & 0 deletions lib/waterdrop/clients.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module WaterDrop
# Namespace for all the clients that WaterDrop may use under the hood
module Clients
end
end
1 change: 0 additions & 1 deletion lib/waterdrop/clients/rdkafka.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

module WaterDrop
# Namespace for all the clients that WaterDrop may use under the hood
module Clients
# Default Rdkafka client.
# Since we use the ::Rdkafka::Producer under the hood, this is just a module that aligns with
Expand Down
7 changes: 7 additions & 0 deletions lib/waterdrop/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module WaterDrop
# Extra internal helper objects
module Helpers
end
end
1 change: 0 additions & 1 deletion lib/waterdrop/helpers/counter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

module WaterDrop
# Extra internal helper objects
module Helpers
# Atomic counter that we can safely increment and decrement without race conditions
class Counter
Expand Down
7 changes: 7 additions & 0 deletions lib/waterdrop/instrumentation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module WaterDrop
# WaterDrop instrumentation related module
module Instrumentation
end
end
9 changes: 9 additions & 0 deletions lib/waterdrop/instrumentation/callbacks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module WaterDrop
module Instrumentation
# Namespace for handlers of callbacks emitted by the kafka client lib
module Callbacks
end
end
end
1 change: 0 additions & 1 deletion lib/waterdrop/instrumentation/callbacks/statistics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

module WaterDrop
module Instrumentation
# Namespace for handlers of callbacks emitted by the kafka client lib
module Callbacks
# Statistics callback handler
# @note We decorate the statistics with our own decorator because some of the metrics from
Expand Down
1 change: 0 additions & 1 deletion lib/waterdrop/instrumentation/logger_listener.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

module WaterDrop
# WaterDrop instrumentation related module
module Instrumentation
# Default listener that hooks up to our instrumentation and uses its events for logging
# It can be removed/replaced or anything without any harm to the Waterdrop flow
Expand Down
9 changes: 9 additions & 0 deletions lib/waterdrop/instrumentation/vendors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module WaterDrop
module Instrumentation
# Namespace for vendor specific instrumentation
module Vendors
end
end
end
11 changes: 11 additions & 0 deletions lib/waterdrop/instrumentation/vendors/datadog.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module WaterDrop
module Instrumentation
module Vendors
# Datadog specific instrumentation
module Datadog
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

module WaterDrop
module Instrumentation
# Namespace for vendor specific instrumentation
module Vendors
# Datadog specific instrumentation
module Datadog
# Listener that can be used to subscribe to WaterDrop producer to receive stats via StatsD
# and/or Datadog
Expand Down
13 changes: 13 additions & 0 deletions spec/lib/waterdrop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,17 @@
it { expect(waterdrop.gem_root.to_path).to eq path }
end
end

describe 'modules files existence' do
let(:lib_location) { File.join(WaterDrop.gem_root, 'lib', 'waterdrop', '**/**') }
let(:candidates) { Dir[lib_location].to_a }

it do
failed = candidates.select do |path|
File.directory?(path) && !File.exist?("#{path}.rb")
end

expect(failed).to eq([])
end
end
end

0 comments on commit b5b13c2

Please sign in to comment.