Class: TalkToYourApp::Plugins::Db::Plugin
- Inherits:
-
TalkToYourApp::Plugin
- Object
- TalkToYourApp::Plugin
- TalkToYourApp::Plugins::Db::Plugin
- Defined in:
- lib/talk_to_your_app/plugins/db/plugin.rb
Overview
The DB plugin: read-only SQL plus schema introspection, all against a separately-configured read-only connection. Requires the operator to declare a :replica_readonly connection; boot fails otherwise.
Class Method Summary collapse
-
.validate_enablement!(_options) ⇒ Object
The read-only guarantee rests on the connection being declared with role: :reading (which enables Rails’ write prevention).
Methods inherited from TalkToYourApp::Plugin
log_level, requires_connection, requires_gem, tools
Class Method Details
.validate_enablement!(_options) ⇒ Object
The read-only guarantee rests on the connection being declared with role: :reading (which enables Rails’ write prevention). Enforce it at boot so a misconfigured :writing role can’t silently expose a writable “read-only” SQL tool. (A missing connection is caught by the ConnectionRegistry validation that runs alongside this.)
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/talk_to_your_app/plugins/db/plugin.rb', line 42 def self.validate_enablement!() return unless TalkToYourApp::ConnectionRegistry.registered?(:replica_readonly) spec = TalkToYourApp::ConnectionRegistry.fetch(:replica_readonly) return if spec.reading? raise TalkToYourApp::ConfigurationError, "talk_to_your_app: the DB plugin's :replica_readonly connection must be declared with " \ "role: :reading (got role: #{spec.role.inspect}). A read-only tool must not run on a writable connection." end |