instance method pubsub_adapter

Ruby on Rails 8.1.2

Since v5.2.8.1

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

pubsub_adapter()

Returns constant of subscription adapter specified in config/cable.yml. If the adapter cannot be found, this will default to the Redis adapter. Also makes sure proper dependencies are required.

Source
# File actioncable/lib/action_cable/server/configuration.rb, line 40
      def pubsub_adapter
        adapter = (cable.fetch("adapter") { "redis" })

        # Require the adapter itself and give useful feedback about
        #     1. Missing adapter gems and
        #     2. Adapter gems' missing dependencies.
        path_to_adapter = "action_cable/subscription_adapter/#{adapter}"
        begin
          require path_to_adapter
        rescue LoadError => e
          # We couldn't require the adapter itself. Raise an exception that points out
          # config typos and missing gems.
          if e.path == path_to_adapter
            # We can assume that a non-builtin adapter was specified, so it's either
            # misspelled or missing from Gemfile.
            raise e.class, "Could not load the '#{adapter}' Action Cable pubsub adapter. Ensure that the adapter is spelled correctly in config/cable.yml and that you've added the necessary adapter gem to your Gemfile.", e.backtrace

          # Bubbled up from the adapter require. Prefix the exception message with some
          # guidance about how to address it and reraise.
          else
            raise e.class, "Error loading the '#{adapter}' Action Cable pubsub adapter. Missing a gem it depends on? #{e.message}", e.backtrace
          end
        end

        adapter = adapter.camelize
        adapter = "PostgreSQL" if adapter == "Postgresql"
        "ActionCable::SubscriptionAdapter::#{adapter}".constantize
      end

Defined in actioncable/lib/action_cable/server/configuration.rb line 40 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionCable::Server::Configuration

Type at least 2 characters to search.

↑↓ navigate · open · esc close