solid_cable 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3be9bb75e998d4747b217592557933db44027b2c0087b9b789141b3f8ee36604
4
- data.tar.gz: 88adf3d11921559c610cc11a59c5776a8f4ed656340c1c51f949fdb431df6fa6
3
+ metadata.gz: 368a0fb2fc95a48908c5ac7c5e0024efc151bd5408d81a16e659cdd1d8be8c27
4
+ data.tar.gz: de55b31627d6cd90aeb38b50b37abe7939e30d1a287c4d896a2c132ded97224b
5
5
  SHA512:
6
- metadata.gz: 756cf4cdd2884b49c1560affba6102366eccff5e8bcf8ec4529a00cf853694d6768e446cc7263cf0ec4ac58f63ed2e7c929ee390ccf0f05909ea6106cb4e6c6d
7
- data.tar.gz: 8c92c0365088b61e733812fad62e3a545ddb05a451cb7316fb1893878159e45b5ea0a0198a43e3e65dedde512842426522747a3c2fdef8b0857614c0ca490ff4
6
+ metadata.gz: 57ef9951de08928ef6a86414d930b67ce0b8ff13bb052fe3be131f5f3ef5593001552e670192de3e98950a2cfc2e24a14ccc959a438adb8d87bcc3ec422e8887
7
+ data.tar.gz: 0bf82c49324bb9d1f4e0416a00c267f6463c87fccc08b51837c876d0ed7327cee0e327b07b08fe75fc4e63ebadfa35b4b183522aaa624f42510bdad3278ed142
data/README.md CHANGED
@@ -20,19 +20,57 @@ Or install it yourself as:
20
20
  $ gem install solid_cable
21
21
  ```
22
22
 
23
- Now, you need to install the necessary migrations and configure Action Cable's adapter.
23
+ Now, you need to run the installer:
24
24
 
25
25
  ```bash
26
26
  $ bin/rails generate solid_cable:install
27
27
  ```
28
28
 
29
- If you want to install to a different database you can pass an env variable.
30
- ```bash
31
- $ DATABASE=cable bin/rails generate solid_cable:install
29
+ This will create the `db/cable_schema.rb` file.
30
+
31
+ You will then have to add the configuration for the database in `config/database.yml`. If you're using SQLite, it'll look something like this:
32
+
33
+ ```yaml
34
+ production:
35
+ primary:
36
+ <<: *default
37
+ database: storage/production.sqlite3
38
+ cable:
39
+ <<: *default
40
+ database: storage/production_cable.sqlite3
41
+ migrations_paths: db/cable_migrate
42
+ ```
43
+
44
+ ...or if you're using MySQL/PostgreSQL/Trilogy:
45
+
46
+ ```yaml
47
+ production:
48
+ primary: &primary_production
49
+ <<: *default
50
+ database: app_production
51
+ username: app
52
+ password: <%= ENV["APP_DATABASE_PASSWORD"] %>
53
+ cable:
54
+ <<: *primary_production
55
+ database: app_production_cable
56
+ migrations_paths: db/cable_migrate
32
57
  ```
33
58
 
34
- Update `config/cable.yml` to use the new adapter. connects_to is can be omitted
35
- if you want to use the primary database.
59
+ > [!NOTE]
60
+ > Calling `bin/rails generate solid_cable:install` will automatically setup `config/cable.yml`, so no additional configuration is needed there (although you must make sure that you use the `cable` name in `database.yml` for this to match!). But if you want to use Solid Cable in a different environment (like staging or even development), you'll have to manually add that `connects_to` block to the respective environment in the `config/cable.yml` file. And, as always, make sure that the name you're using for the database in `config/cable.yml` matches the name you define in `config/database.yml`.
61
+
62
+ Then run `db:prepare` in production to ensure the database is created and the schema is loaded.
63
+
64
+ ## Usage
65
+
66
+ By default messages are kept around forever. SolidCable ships with a job to
67
+ prune messages. You can run `SolidCable::PruneJob.perform_later` which removes
68
+ Messages that are older than what is specified in `keep_messages_around_for`
69
+ setting.
70
+
71
+ ## Configuration
72
+
73
+ All configuration is managed via the `config/cable.yml`file. To use Solid Cable, the `adapter` value *must be* `solid_cable`. When using Solid Cable, the other values you can set are: `connects_to`, `polling_interval`, `silence_polling`, and `keep_messages_around_for`. For example:
36
74
 
37
75
  ```yaml
38
76
  default: &default
@@ -56,16 +94,5 @@ production:
56
94
  polling_interval: 0.1.seconds
57
95
  ```
58
96
 
59
- Finally, you need to run the migrations:
60
-
61
- ```bash
62
- $ bin/rails db:migrate
63
- ```
64
-
65
- By default messages are kept around forever. SolidCable ships with a job to
66
- prune messages. You can run `SolidCable::PruneJob.perform_later` which removes
67
- Messages that are older than what is specified in `keep_messages_around_for`
68
- setting.
69
-
70
97
  ## License
71
98
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -3,19 +3,27 @@
3
3
  class SolidCable::InstallGenerator < Rails::Generators::Base
4
4
  source_root File.expand_path("templates", __dir__)
5
5
 
6
- class_option :database,
7
- type: :string, aliases: %i(--db),
8
- desc: "The database for your migration. By default, the " \
9
- "current environment's primary database is used."
10
- class_option :skip_migrations, type: :boolean, default: nil,
11
- desc: "Skip migrations"
6
+ def add_solid_errors_db_schema
7
+ template "db/cable_schema.rb"
8
+ end
12
9
 
13
- def create_migrations
14
- return if options[:skip_migrations]
10
+ def configure_production_cable
11
+ gsub_file("config/cable.yml",
12
+ /production:\n(^\s*.*$\n){2,}/,
13
+ new_production_cable_config)
14
+ end
15
15
 
16
- db_clause = "DATABASE=#{options[:database]}" if options[:database].present?
16
+ private
17
17
 
18
- rails_command "railties:install:migrations FROM=solid_cable #{db_clause}".strip,
19
- inline: true
18
+ def new_production_cable_config
19
+ <<~YAML
20
+ production:
21
+ adapter: solid_cable
22
+ connects_to:
23
+ database:
24
+ writing: cable
25
+ polling_interval: 0.1.seconds
26
+ keep_messages_around_for: 1.day
27
+ YAML
20
28
  end
21
29
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ ActiveRecord::Schema[7.1].define(version: 1) do
4
+ create_table "solid_cable_messages", force: :cascade do |t|
5
+ t.text "channel"
6
+ t.text "payload"
7
+ t.datetime "created_at", null: false
8
+ t.datetime "updated_at", null: false
9
+ t.index ["channel"], name: "index_solid_cable_messages_on_channel",
10
+ length: 500
11
+ t.index ["created_at"], name: "index_solid_cable_messages_on_created_at"
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidCable
4
+ class Railtie < ::Rails::Railtie
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidCable
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.5"
5
5
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_cable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-20 00:00:00.000000000 Z
11
+ date: 2024-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "<"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '9'
19
+ version: '7.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "<"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '9'
26
+ version: '7.2'
27
27
  description: Database-backed Action Cable backend.
28
28
  email:
29
29
  - pezza@hey.com
@@ -37,13 +37,13 @@ files:
37
37
  - app/jobs/solid_cable/prune_job.rb
38
38
  - app/models/solid_cable/message.rb
39
39
  - app/models/solid_cable/record.rb
40
- - db/migrate/20240103034713_create_solid_cable_message.rb
41
- - db/migrate/20240607184711_index_channels.rb
42
40
  - lib/action_cable/subscription_adapter/solid_cable.rb
43
41
  - lib/generators/solid_cable/install/USAGE
44
42
  - lib/generators/solid_cable/install/install_generator.rb
43
+ - lib/generators/solid_cable/install/templates/db/cable_schema.rb
45
44
  - lib/solid_cable.rb
46
45
  - lib/solid_cable/engine.rb
46
+ - lib/solid_cable/railtie.rb
47
47
  - lib/solid_cable/version.rb
48
48
  homepage: http://github.com/npezza93/solid_cable
49
49
  licenses:
@@ -60,14 +60,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: '0'
63
+ version: 3.1.0
64
64
  required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
- rubygems_version: 3.5.9
70
+ rubygems_version: 3.5.18
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: Database-backed Action Cable backend.
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateSolidCableMessage < ActiveRecord::Migration[7.1]
4
- def change
5
- create_table :solid_cable_messages, if_not_exists: true do |t|
6
- t.text :channel
7
- t.text :payload
8
-
9
- t.timestamps
10
-
11
- t.index :created_at
12
- end
13
- end
14
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class IndexChannels < ActiveRecord::Migration[7.1]
4
- def change
5
- add_index :solid_cable_messages, :channel, length: 500
6
- end
7
- end