solid_cable 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -2
- data/app/models/solid_cable/message.rb +3 -1
- data/lib/action_cable/subscription_adapter/solid_cable.rb +1 -1
- data/lib/solid_cable/version.rb +1 -1
- data/lib/solid_cable.rb +15 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdc881f5bdbc42849563b7a04165bd1681810bd938fa9d7edb293c0d59ecc098
|
4
|
+
data.tar.gz: 560d1ad6d1583e360617157d2cc6f87f3b611dd9f408bad200801e20d773513a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2059991512cf183a42448deabbd5a48946b3ff6d7412d405ef92c1fea4dad7b5816539efdd671c6c0fd475b43dc1c6295fc920b87e042663454914d49bb7c18c
|
7
|
+
data.tar.gz: a8a895d63fca959c60ff5c63ab349c5c7c7414646dd95a88167b2c7d7a92f228a180ecb71f35b2ed84208f80242f6417cf185e4a6ba72e6e5b44a223de6b39bc
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SolidCable
|
2
2
|
|
3
|
-
Solid Cable is a DB-based
|
3
|
+
Solid Cable is a DB-based backend for Action Cable.
|
4
4
|
|
5
5
|
|
6
6
|
## Installation
|
@@ -20,7 +20,7 @@ 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
|
23
|
+
Now, you need to install the necessary migrations and configure Action Cable's adapter.
|
24
24
|
|
25
25
|
```bash
|
26
26
|
$ bin/rails generate solid_cable:install
|
@@ -31,12 +31,17 @@ Update `config/cable.yml` to use the new adapter:
|
|
31
31
|
```yaml
|
32
32
|
development:
|
33
33
|
adapter: solid_cable
|
34
|
+
silence_polling: true
|
35
|
+
polling_interval: 1
|
36
|
+
keep_messages_around_for: 30.minutes
|
34
37
|
|
35
38
|
test:
|
36
39
|
adapter: test
|
37
40
|
|
38
41
|
production:
|
39
42
|
adapter: solid_cable
|
43
|
+
polling_interval: 0.1
|
44
|
+
keep_messages_around_for: 10.minutes
|
40
45
|
```
|
41
46
|
|
42
47
|
Finally, you need to run the migrations:
|
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
module SolidCable
|
4
4
|
class Message < SolidCable::Record
|
5
|
-
scope :prunable,
|
5
|
+
scope :prunable, lambda {
|
6
|
+
where(created_at: ..SolidCable.keep_messages_around_for.ago)
|
7
|
+
}
|
6
8
|
scope :broadcastable, lambda { |channels, last_id|
|
7
9
|
where(channel: channels).where(id: (last_id + 1)..).order(:id)
|
8
10
|
}
|
data/lib/solid_cable/version.rb
CHANGED
data/lib/solid_cable.rb
CHANGED
@@ -10,4 +10,19 @@ module SolidCable
|
|
10
10
|
def self.silence_polling?
|
11
11
|
!!Rails.application.config_for("cable")[:silence_polling]
|
12
12
|
end
|
13
|
+
|
14
|
+
def self.polling_interval
|
15
|
+
Rails.application.config_for("cable")[:polling_interval].presence || 0.1
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.keep_messages_around_for
|
19
|
+
duration = Rails.application.config_for("cable")[:keep_messages_around_for]
|
20
|
+
|
21
|
+
if duration.present?
|
22
|
+
amount, units = duration.to_s.split(".")
|
23
|
+
amount.to_i.public_send(units)
|
24
|
+
else
|
25
|
+
30.minutes
|
26
|
+
end
|
27
|
+
end
|
13
28
|
end
|