solid_cable 0.1.0 → 0.2.1

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: '00408473f35ef85d126584f435899efb2e921a9094c15b5a79bc76a975268adf'
4
- data.tar.gz: 690b0c1bb50e20e17facb9255bdeb98f38877c02929903c518b826093a7e806a
3
+ metadata.gz: 6f21d57b5c3c839b30ef880bb84c02fe5e375d3674d282a1b8541e1d86b131a4
4
+ data.tar.gz: 2b58076180cb59dcfd61f5c39620d14399ce0cbf14c681038488e404ed3f81a6
5
5
  SHA512:
6
- metadata.gz: 702654c332b42fab18bf27b427151617462d6d4ab42f81e29b50ba6adf106eefff3bb149b58da169dbed14221f8e68c6efe04148db385fd9bb9b8840f004f6d6
7
- data.tar.gz: 2733a331ac2e4ca7b1ced62247ffeda561cb48615c6a9a33f1af6056bbda63f269d9eaa1e840d9dee51d23426406589b7d1bb5800fa6bf37851a59c7fae723e1
6
+ metadata.gz: 2fe8d98cd77a1db28afa1e3d2c4a917f8eb1741ea56969974fb9944ba43f9a46f20e49204b40315fccb7aa8534cf143c2cd225d93c85ff5b1454690f6e3eb2b9
7
+ data.tar.gz: c254587b2e46bac28c16cfe0dd7c25631fff6ec4930c38be4e4dda63acb70a74b5a194b9a9ed3060361b56eac6f07f4462672ae74fbc69bda024b6ebec4dae51
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.1"
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza