solid_cable 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '00408473f35ef85d126584f435899efb2e921a9094c15b5a79bc76a975268adf'
4
- data.tar.gz: 690b0c1bb50e20e17facb9255bdeb98f38877c02929903c518b826093a7e806a
3
+ metadata.gz: fdc881f5bdbc42849563b7a04165bd1681810bd938fa9d7edb293c0d59ecc098
4
+ data.tar.gz: 560d1ad6d1583e360617157d2cc6f87f3b611dd9f408bad200801e20d773513a
5
5
  SHA512:
6
- metadata.gz: 702654c332b42fab18bf27b427151617462d6d4ab42f81e29b50ba6adf106eefff3bb149b58da169dbed14221f8e68c6efe04148db385fd9bb9b8840f004f6d6
7
- data.tar.gz: 2733a331ac2e4ca7b1ced62247ffeda561cb48615c6a9a33f1af6056bbda63f269d9eaa1e840d9dee51d23426406589b7d1bb5800fa6bf37851a59c7fae723e1
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 queuing backend for Action Cabble, designed with simplicity and performance in mind.
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 the Action Cable's adapter.
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, -> { where(created_at: ..30.minutes.ago) }
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
  }
@@ -48,7 +48,7 @@ module ActionCable
48
48
  while running?
49
49
  with_polling_volume { broadcast_messages }
50
50
 
51
- sleep 0.5
51
+ sleep SolidCable.polling_interval
52
52
  end
53
53
  end
54
54
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidCable
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_cable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza