The with_advisory_lock gem integrates with ActiveRecord via ActiveSupport hooks. When required in a standard Ruby environment (MRI or TruffleRuby), it automatically includes WithAdvisoryLock::Concern into ActiveRecord::Base and prepends the appropriate database-specific advisory lock modules to your connection adapters.
Supported adapter integrations include:
- PostgreSQL: Uses
WithAdvisoryLock::CoreAdvisory and WithAdvisoryLock::PostgreSQLAdvisory. - MySQL (mysql2): Uses
WithAdvisoryLock::CoreAdvisory and WithAdvisoryLock::MySQLAdvisory. - Trilogy: Uses
WithAdvisoryLock::CoreAdvisory and WithAdvisoryLock::MySQLAdvisory.
For JRuby, the gem uses a specialized JRubyAdapter which is installed via WithAdvisoryLock::JRubyAdapter.install! to ensure compatibility.