Skip to content

Commit

Permalink
Merge pull request #219 from bigcommerce/fix_build
Browse files Browse the repository at this point in the history
Fix build
  • Loading branch information
splittingred authored Jan 6, 2025
2 parents e8947be + 1cf26e9 commit db34fee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/gruf/autoloaders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,26 @@ def reload
#
# @return [::Gruf::Controllers::Autoloader]
#
# rubocop:disable ThreadSafety/InstanceVariableInClassMethod
# rubocop:disable ThreadSafety/ClassInstanceVariable
def controllers(controllers_path: nil)
controllers_mutex do
@controllers ||= ::Gruf::Controllers::Autoloader.new(path: controllers_path || ::Gruf.controllers_path)
end
end
# rubocop:enable ThreadSafety/InstanceVariableInClassMethod
# rubocop:enable ThreadSafety/ClassInstanceVariable

##
# Handle mutations to the controllers autoloader in a thread-safe manner
#
# rubocop:disable ThreadSafety/InstanceVariableInClassMethod
# rubocop:disable ThreadSafety/ClassInstanceVariable
def controllers_mutex(&block)
@controllers_mutex ||= begin
require 'monitor'
Monitor.new
end
@controllers_mutex.synchronize(&block)
end
# rubocop:enable ThreadSafety/InstanceVariableInClassMethod
# rubocop:enable ThreadSafety/ClassInstanceVariable
end
end
end
4 changes: 2 additions & 2 deletions lib/gruf/controllers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def self.bind(service)
service_class = service.name.constantize
::Gruf.logger.debug "[gruf] Binding #{service_class} to #{name}"
::Gruf.services << service_class
# rubocop:disable ThreadSafety/InstanceVariableInClassMethod
# rubocop:disable ThreadSafety/ClassInstanceVariable
@bound_service = service_class
# rubocop:enable ThreadSafety/InstanceVariableInClassMethod
# rubocop:enable ThreadSafety/ClassInstanceVariable
ServiceBinder.bind!(service: service_class, controller: self)
end

Expand Down

0 comments on commit db34fee

Please sign in to comment.