solid_cable 3.0.5 → 3.0.7
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/lib/action_cable/subscription_adapter/solid_cable.rb +36 -26
 - data/lib/solid_cable/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c539a7fa2b2a380a1eba731b6b648a50cab649feeafffac427e37a283fa14ca3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2b067b5c80b211a0e89b8d72a46ed4559e9c880e9845688cdc3ea11a3e3527c1
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: dd4c81ee1b1e2bd2f024fed7b1561b8eb24d8fb7f2ee16e7efce9dd0a3409a197446936194a272cecc293e81e62e119ad7100395ba6c5fc453b0213e5415adca
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: f30f1987f739b5a7b0afded103e3cf337343570b7483f2118f47116e325cd0a7db2865363e560b3c9dcd689291c55fd4c128eebe56be3d7d8411f53d6d41b2c0
         
     | 
| 
         @@ -3,6 +3,7 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require "action_cable/subscription_adapter/base"
         
     | 
| 
       4 
4 
     | 
    
         
             
            require "action_cable/subscription_adapter/channel_prefix"
         
     | 
| 
       5 
5 
     | 
    
         
             
            require "action_cable/subscription_adapter/subscriber_map"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "concurrent/atomic/semaphore"
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
8 
     | 
    
         
             
            module ActionCable
         
     | 
| 
       8 
9 
     | 
    
         
             
              module SubscriptionAdapter
         
     | 
| 
         @@ -38,34 +39,53 @@ module ActionCable 
     | 
|
| 
       38 
39 
     | 
    
         
             
                    end
         
     | 
| 
       39 
40 
     | 
    
         | 
| 
       40 
41 
     | 
    
         
             
                    class Listener < ::ActionCable::SubscriptionAdapter::SubscriberMap
         
     | 
| 
      
 42 
     | 
    
         
            +
                      Stop = Class.new(Exception)
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       41 
44 
     | 
    
         
             
                      def initialize(event_loop)
         
     | 
| 
       42 
45 
     | 
    
         
             
                        super()
         
     | 
| 
       43 
46 
     | 
    
         | 
| 
       44 
47 
     | 
    
         
             
                        @event_loop = event_loop
         
     | 
| 
       45 
48 
     | 
    
         | 
| 
      
 49 
     | 
    
         
            +
                        # Critical section begins with 0 permits. It can be understood as
         
     | 
| 
      
 50 
     | 
    
         
            +
                        # being "normally held" by the listener thread. It is released
         
     | 
| 
      
 51 
     | 
    
         
            +
                        # for specific sections of code, rather than acquired.
         
     | 
| 
      
 52 
     | 
    
         
            +
                        @critical = Concurrent::Semaphore.new(0)
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
       46 
54 
     | 
    
         
             
                        @thread = Thread.new do
         
     | 
| 
       47 
     | 
    
         
            -
                          Thread.current.abort_on_exception = true
         
     | 
| 
       48 
55 
     | 
    
         
             
                          listen
         
     | 
| 
       49 
56 
     | 
    
         
             
                        end
         
     | 
| 
       50 
57 
     | 
    
         
             
                      end
         
     | 
| 
       51 
58 
     | 
    
         | 
| 
       52 
59 
     | 
    
         
             
                      def listen
         
     | 
| 
       53 
60 
     | 
    
         
             
                        loop do
         
     | 
| 
       54 
     | 
    
         
            -
                           
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
      
 61 
     | 
    
         
            +
                          begin
         
     | 
| 
      
 62 
     | 
    
         
            +
                            instance = interruptible { Rails.application.executor.run! }
         
     | 
| 
      
 63 
     | 
    
         
            +
                            with_polling_volume { broadcast_messages }
         
     | 
| 
      
 64 
     | 
    
         
            +
                          ensure
         
     | 
| 
      
 65 
     | 
    
         
            +
                            instance.complete! if instance
         
     | 
| 
      
 66 
     | 
    
         
            +
                          end
         
     | 
| 
       57 
67 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
                           
     | 
| 
      
 68 
     | 
    
         
            +
                          interruptible { sleep ::SolidCable.polling_interval }
         
     | 
| 
       59 
69 
     | 
    
         
             
                        end
         
     | 
| 
      
 70 
     | 
    
         
            +
                      rescue Stop
         
     | 
| 
      
 71 
     | 
    
         
            +
                      ensure
         
     | 
| 
      
 72 
     | 
    
         
            +
                        @critical.release
         
     | 
| 
       60 
73 
     | 
    
         
             
                      end
         
     | 
| 
       61 
74 
     | 
    
         | 
| 
       62 
     | 
    
         
            -
                      def  
     | 
| 
       63 
     | 
    
         
            -
                         
     | 
| 
       64 
     | 
    
         
            -
                         
     | 
| 
      
 75 
     | 
    
         
            +
                      def interruptible
         
     | 
| 
      
 76 
     | 
    
         
            +
                        @critical.release
         
     | 
| 
      
 77 
     | 
    
         
            +
                        yield
         
     | 
| 
      
 78 
     | 
    
         
            +
                      ensure
         
     | 
| 
      
 79 
     | 
    
         
            +
                        @critical.acquire
         
     | 
| 
      
 80 
     | 
    
         
            +
                      end
         
     | 
| 
       65 
81 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                         
     | 
| 
      
 82 
     | 
    
         
            +
                      def shutdown
         
     | 
| 
      
 83 
     | 
    
         
            +
                        @critical.acquire
         
     | 
| 
      
 84 
     | 
    
         
            +
                        # We have the critical permit, and so the listen thread must be
         
     | 
| 
      
 85 
     | 
    
         
            +
                        # safe to interrupt.
         
     | 
| 
      
 86 
     | 
    
         
            +
                        thread.raise(Stop)
         
     | 
| 
      
 87 
     | 
    
         
            +
                        @critical.release
         
     | 
| 
      
 88 
     | 
    
         
            +
                        thread.join
         
     | 
| 
       69 
89 
     | 
    
         
             
                      end
         
     | 
| 
       70 
90 
     | 
    
         | 
| 
       71 
91 
     | 
    
         
             
                      def add_channel(channel, on_success)
         
     | 
| 
         @@ -83,15 +103,7 @@ module ActionCable 
     | 
|
| 
       83 
103 
     | 
    
         | 
| 
       84 
104 
     | 
    
         
             
                      private
         
     | 
| 
       85 
105 
     | 
    
         
             
                        attr_reader :event_loop, :thread
         
     | 
| 
       86 
     | 
    
         
            -
                        attr_writer : 
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
                        def running?
         
     | 
| 
       89 
     | 
    
         
            -
                          if defined?(@running)
         
     | 
| 
       90 
     | 
    
         
            -
                            @running
         
     | 
| 
       91 
     | 
    
         
            -
                          else
         
     | 
| 
       92 
     | 
    
         
            -
                            self.running = true
         
     | 
| 
       93 
     | 
    
         
            -
                          end
         
     | 
| 
       94 
     | 
    
         
            -
                        end
         
     | 
| 
      
 106 
     | 
    
         
            +
                        attr_writer :last_id
         
     | 
| 
       95 
107 
     | 
    
         | 
| 
       96 
108 
     | 
    
         
             
                        def last_id
         
     | 
| 
       97 
109 
     | 
    
         
             
                          @last_id ||= ::SolidCable::Message.maximum(:id) || 0
         
     | 
| 
         @@ -102,12 +114,10 @@ module ActionCable 
     | 
|
| 
       102 
114 
     | 
    
         
             
                        end
         
     | 
| 
       103 
115 
     | 
    
         | 
| 
       104 
116 
     | 
    
         
             
                        def broadcast_messages
         
     | 
| 
       105 
     | 
    
         
            -
                           
     | 
| 
       106 
     | 
    
         
            -
                             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
                                self.last_id = message.id
         
     | 
| 
       110 
     | 
    
         
            -
                            end
         
     | 
| 
      
 117 
     | 
    
         
            +
                          ::SolidCable::Message.broadcastable(channels, last_id).
         
     | 
| 
      
 118 
     | 
    
         
            +
                            each do |message|
         
     | 
| 
      
 119 
     | 
    
         
            +
                            broadcast(message.channel, message.payload)
         
     | 
| 
      
 120 
     | 
    
         
            +
                            self.last_id = message.id
         
     | 
| 
       111 
121 
     | 
    
         
             
                          end
         
     | 
| 
       112 
122 
     | 
    
         
             
                        end
         
     | 
| 
       113 
123 
     | 
    
         | 
    
        data/lib/solid_cable/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: solid_cable
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 3.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 3.0.7
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Nick Pezza
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2025-01-25 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activerecord
         
     |