solid_cable 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +44 -17
- data/lib/generators/solid_cable/install/install_generator.rb +28 -11
- data/lib/generators/solid_cable/install/templates/cable_schema.rb +13 -0
- data/lib/solid_cable/railtie.rb +6 -0
- data/lib/solid_cable/version.rb +1 -1
- metadata +10 -10
- data/db/migrate/20240103034713_create_solid_cable_message.rb +0 -14
- data/db/migrate/20240607184711_index_channels.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 308be2095ff346a9b56b60f08d26adfabd2c2cfa24dbbf83f7e7df1a0b230b0e
|
4
|
+
data.tar.gz: 2875794b63122cb4b11297de037c733d8c91969e1372c1ebfc68dfdf21e7d04d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 113f33268a0056e6233e3c4649f8a1acdbada127439ce47c1784e3c0f733ab7be68223f98b3f624ff7262ea21ec97a8480f52539995430e6f745c2075fca34ad
|
7
|
+
data.tar.gz: d153dfb2ac483315464cf2e3d4c870a4524c34ba48298e940511601ca9eae2d1ce07dcad5947426fcf3e4e9db2a694a4b6bd4f12cd854c1208384fa83707d59f
|
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
|
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
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
35
|
-
if you want to use the
|
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,36 @@
|
|
3
3
|
class SolidCable::InstallGenerator < Rails::Generators::Base
|
4
4
|
source_root File.expand_path("templates", __dir__)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
def add_solid_errors_db_schema
|
7
|
+
template "cable_schema.rb"
|
8
|
+
end
|
9
|
+
|
10
|
+
def configure_production_cable
|
11
|
+
gsub_file("config/cable.yml",
|
12
|
+
old_production_cable_config,
|
13
|
+
new_production_cable_config)
|
14
|
+
end
|
12
15
|
|
13
|
-
|
14
|
-
return if options[:skip_migrations]
|
16
|
+
private
|
15
17
|
|
16
|
-
|
18
|
+
def old_production_cable_config
|
19
|
+
<<~YAML
|
20
|
+
production:
|
21
|
+
adapter: redis
|
22
|
+
url: <%%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
|
23
|
+
channel_prefix: <%= app_name %>_production
|
24
|
+
YAML
|
25
|
+
end
|
17
26
|
|
18
|
-
|
19
|
-
|
27
|
+
def new_production_cable_config
|
28
|
+
<<~YAML
|
29
|
+
production:
|
30
|
+
adapter: solid_cable
|
31
|
+
connects_to:
|
32
|
+
database:
|
33
|
+
writing: cable
|
34
|
+
polling_interval: 0.1.seconds
|
35
|
+
keep_messages_around_for: 1.day
|
36
|
+
YAML
|
20
37
|
end
|
21
38
|
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
|
data/lib/solid_cable/version.rb
CHANGED
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.
|
4
|
+
version: 1.0.4
|
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-
|
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: '
|
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: '
|
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/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:
|
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.
|
70
|
+
rubygems_version: 3.5.17
|
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
|