jason-rails 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +7 -2
- data/app/controllers/jason/{api_controller.rb → jason_controller.rb} +1 -1
- data/app/controllers/jason/{api/pusher_controller.rb → pusher_controller.rb} +1 -1
- data/app/workers/jason/outbound_message_queue_worker.rb +21 -0
- data/client/package.json +1 -1
- data/config/routes.rb +6 -6
- data/jason-rails.gemspec +1 -0
- data/lib/jason.rb +2 -0
- data/lib/jason/broadcaster.rb +2 -1
- data/lib/jason/publisher.rb +3 -1
- data/lib/jason/version.rb +1 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48abc57aac9f4529a93812d46422ac21d48e58432fc21e570f1801b84a3ac436
|
4
|
+
data.tar.gz: ac21dab5464e5dd254a1a223a80581c1410c928bab4c0fbc9fe32cdfedb7c474
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09c42d2b035af32efdc006224e3e81fa398d2327199845640ff7c710c7cecbd0c5edd9d18e441b5b3fefb2a356f45159c77194ed72f866880171071fb302c422'
|
7
|
+
data.tar.gz: 1b5f4f16a5032ca96f8106dc4fff8c8a1a1d5792392b4ed28ad9f1c8974848dec5359e4bb0bc675463cc923e5f77552b6bcfda6c733bf72bb66f156648ce521c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## v0.6.6
|
2
|
+
- Fix: don't run the schema change detection and cache rebuild inside rake tasks or migrations
|
3
|
+
|
1
4
|
## v0.6.5
|
2
5
|
- Added `reset!` and `reset!(hard: true)` methods to `Subscription`. Reset will load the IDs that should be part of the subscription from the database, and ensure that the graph matches those. It then re-broadcasts the payloads to all connected clients. Hard reset will do the same, but also clear all cached IDs and subscription hooks on instances - this is equivalent from starting from scratch.
|
3
6
|
- Added `enforce: boolean` option to GraphHelper
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jason-rails (0.6.
|
4
|
+
jason-rails (0.6.6)
|
5
5
|
connection_pool (>= 2.2.3)
|
6
6
|
jsondiff
|
7
7
|
rails (>= 5)
|
@@ -93,7 +93,7 @@ GEM
|
|
93
93
|
mini_mime (1.0.2)
|
94
94
|
mini_portile2 (2.5.0)
|
95
95
|
minitest (5.14.3)
|
96
|
-
nio4r (2.5.
|
96
|
+
nio4r (2.5.5)
|
97
97
|
nokogiri (1.11.1)
|
98
98
|
mini_portile2 (~> 2.5.0)
|
99
99
|
racc (~> 1.4)
|
@@ -153,6 +153,10 @@ GEM
|
|
153
153
|
rspec-mocks (~> 3.10)
|
154
154
|
rspec-support (~> 3.10)
|
155
155
|
rspec-support (3.10.0)
|
156
|
+
sidekiq (6.1.3)
|
157
|
+
connection_pool (>= 2.2.2)
|
158
|
+
rack (~> 2.0)
|
159
|
+
redis (>= 4.2.0)
|
156
160
|
sprockets (4.0.2)
|
157
161
|
concurrent-ruby (~> 1.0)
|
158
162
|
rack (> 1, < 3)
|
@@ -178,6 +182,7 @@ DEPENDENCIES
|
|
178
182
|
rake (~> 12.0)
|
179
183
|
rspec (~> 3.0)
|
180
184
|
rspec-rails
|
185
|
+
sidekiq
|
181
186
|
sqlite3
|
182
187
|
|
183
188
|
BUNDLED WITH
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Jason::
|
1
|
+
class Jason::JasonController < ::ApplicationController
|
2
2
|
before_action :load_and_authorize_subscription, only: [:create_subscription, :remove_subscription, :get_payload]
|
3
3
|
# config seems to be a reserved name, resulting in infinite loop
|
4
4
|
def configuration
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Jason::OutboundMessageQueueWorker
|
2
|
+
include Sidekiq::Worker
|
3
|
+
|
4
|
+
def perform
|
5
|
+
batch = get_batch
|
6
|
+
return if batch.size == 0
|
7
|
+
|
8
|
+
Jason.pusher.trigger_batch(batch)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def get_batch
|
14
|
+
batch_json = $redis_jason.multi do |r|
|
15
|
+
r.lrange("jason:outbound_message_queue", 0, 9) # get first 10 elements
|
16
|
+
r.ltrim("jason:outbound_message_queue", 10, -1) # delete first 10 elements
|
17
|
+
end[0]
|
18
|
+
|
19
|
+
batch_json.map { |event| JSON.parse(event).with_indifferent_access } # Pusher wants symbol keys
|
20
|
+
end
|
21
|
+
end
|
data/client/package.json
CHANGED
data/config/routes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Jason::Engine.routes.draw do
|
2
|
-
get '/api/config', to: '
|
3
|
-
post '/api/action', to: '
|
4
|
-
post '/api/create_subscription', to: '
|
5
|
-
post '/api/remove_subscription', to: '
|
6
|
-
post '/api/get_payload', to: '
|
7
|
-
post '/api/pusher/auth', to: '
|
2
|
+
get '/api/config', to: 'jason#configuration'
|
3
|
+
post '/api/action', to: 'jason#action'
|
4
|
+
post '/api/create_subscription', to: 'jason#create_subscription'
|
5
|
+
post '/api/remove_subscription', to: 'jason#remove_subscription'
|
6
|
+
post '/api/get_payload', to: 'jason#get_payload'
|
7
|
+
post '/api/pusher/auth', to: 'pusher#auth'
|
8
8
|
end
|
data/jason-rails.gemspec
CHANGED
data/lib/jason.rb
CHANGED
@@ -24,11 +24,13 @@ module Jason
|
|
24
24
|
self.mattr_accessor :pusher_region
|
25
25
|
self.mattr_accessor :pusher_channel_prefix
|
26
26
|
self.mattr_accessor :authorization_service
|
27
|
+
self.mattr_accessor :sidekiq_queue
|
27
28
|
|
28
29
|
self.schema = {}
|
29
30
|
self.transport_service = :action_cable
|
30
31
|
self.pusher_region = 'eu'
|
31
32
|
self.pusher_channel_prefix = 'jason'
|
33
|
+
self.sidekiq_queue = 'default'
|
32
34
|
|
33
35
|
def self.init
|
34
36
|
# Don't run in AR migration / generator etc.
|
data/lib/jason/broadcaster.rb
CHANGED
@@ -13,7 +13,8 @@ class Jason::Broadcaster
|
|
13
13
|
if Jason.transport_service == :action_cable
|
14
14
|
ActionCable.server.broadcast(channel, message)
|
15
15
|
elsif Jason.transport_service == :pusher
|
16
|
-
|
16
|
+
$redis_jason.rpush("jason:outbound_message_queue", { channel: pusher_channel_name, name: 'changed', data: message }.to_json)
|
17
|
+
Jason::OutboundMessageQueueWorker.perform_async
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
data/lib/jason/publisher.rb
CHANGED
@@ -42,7 +42,9 @@ module Jason::Publisher
|
|
42
42
|
# - TODO: The value of an instance changes so that it enters/leaves a subscription
|
43
43
|
|
44
44
|
# TODO: Optimize this, by caching associations rather than checking each time instance is saved
|
45
|
-
jason_assocs = self.class.reflect_on_all_associations(:belongs_to)
|
45
|
+
jason_assocs = self.class.reflect_on_all_associations(:belongs_to)
|
46
|
+
.reject { |assoc| assoc.polymorphic? } # Can't get the class name of a polymorphic association, by
|
47
|
+
.select { |assoc| assoc.klass.respond_to?(:has_jason?) }
|
46
48
|
jason_assocs.each do |assoc|
|
47
49
|
if previous_changes[assoc.foreign_key].present?
|
48
50
|
Jason::Subscription.update_ids(
|
data/lib/jason/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jason-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Rees
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sidekiq
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description:
|
112
126
|
email:
|
113
127
|
- jarees@gmail.com
|
@@ -126,8 +140,9 @@ files:
|
|
126
140
|
- LICENSE.txt
|
127
141
|
- README.md
|
128
142
|
- Rakefile
|
129
|
-
- app/controllers/jason/
|
130
|
-
- app/controllers/jason/
|
143
|
+
- app/controllers/jason/jason_controller.rb
|
144
|
+
- app/controllers/jason/pusher_controller.rb
|
145
|
+
- app/workers/jason/outbound_message_queue_worker.rb
|
131
146
|
- bin/console
|
132
147
|
- bin/setup
|
133
148
|
- client/babel.config.js
|