rails / solid_cable

A database backed ActionCable adapter
MIT License
121 stars 7 forks source link

Error trying to use a different database #3

Closed SrAnthony closed 3 months ago

SrAnthony commented 3 months ago

I'm using this setup on my database.yml:

default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 10000

primary: &primary
  <<: *default
  database: storage/<%= Rails.env %>/data.sqlite3

cable: &cable
  <<: *default
  migrations_paths: db/cable_migrate
  database: storage/<%= Rails.env %>/cable.sqlite3

development:
  primary: *primary
  queue: *queue
  cache: *cache
  cable: *cable

Then, when trying to setup solid cache like this:

default: &default
  adapter: solid_cable
  connects_to:
    database:
      writing: cable
      reading: cable

development:
  <<: *default

I get the error: '{ development => cable }' is not a valid configuration. Expected 'cable' to be a URL string or a Hash. (ActiveRecord::DatabaseConfigurations::InvalidConfigurationError)

Am I missing something?

I'm using solid cache and solid queue using that database.yml setup without problems.

SrAnthony commented 3 months ago

Btw solid queue is configured like this in the application.rb:

config.solid_queue.connects_to = { database: { writing: :queue, reading: :queue } }

And solid cache on solid_cache.yml:

development:
  database: cache

production:
  database: cache
activefx commented 3 months ago

Passing the name of the connection as a symbol worked for me:

default: &default
  adapter: solid_cable
  polling_interval: 1.second
  keep_messages_around_for: 1.day
  connects_to:
    database:
      writing: :cable
      reading: :cable

development:
  <<: *default
  silence_polling: true

test:
  adapter: test

production:
  <<: *default
  polling_interval: 0.1.seconds
  keep_messages_around_for: 10.minutes
npezza93 commented 3 months ago

Just cut 1.0.2 which should fix this