hyper-resource 1.0.0.lap76 → 1.0.0.lap77
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hyper_record/pub_sub.rb +113 -72
- data/lib/hyperloop/resource/pub_sub.rb +84 -66
- data/lib/hyperloop/resource/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: 4564204f79d886ec827b4fdafa1d153ce63b111dd1fc57faaadd47efb53a5dfc
|
4
|
+
data.tar.gz: 325ec362368ddc0e94434f67e665b002b3a47f4ee485e624a3d2b9c5a6e9ba8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 983c55f79ca78190707d810008b5e86f0bcad611fb921b5d87b68b5ab0d11d00074cc7a216ab5f00fec80e5e2faef7f313f1ddb1f2ad75b9b2c0e1d1a3dbb012
|
7
|
+
data.tar.gz: ccec9ccfea294761cd2a876fd5094c385ea78d57162707754dd2d1b410e7133adf5f77e28751f0fd818d304202acdd887abd6f36ee1c70d6be2992240ed2fdb4
|
data/lib/hyper_record/pub_sub.rb
CHANGED
@@ -18,6 +18,35 @@ module HyperRecord
|
|
18
18
|
)
|
19
19
|
end
|
20
20
|
|
21
|
+
def publish_record(record)
|
22
|
+
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record.class}__#{record.id}")
|
23
|
+
time_now = Time.now.to_f
|
24
|
+
scrub_time = time_now - 24.hours.to_f
|
25
|
+
|
26
|
+
message = {
|
27
|
+
record_type: record.class.to_s,
|
28
|
+
id: record.id,
|
29
|
+
updated_at: record.updated_at
|
30
|
+
}
|
31
|
+
message[:destroyed] = true if record.destroyed?
|
32
|
+
|
33
|
+
# can only trigger to max 10 channels at once on pusher
|
34
|
+
subscribers.each_slice(10) do |slice|
|
35
|
+
channel_array = []
|
36
|
+
slice.each do |session_id, last_requested|
|
37
|
+
if last_requested.to_f < scrub_time
|
38
|
+
Hyperloop.redis_instance.hdel("HRPS__#{record.class}__#{record.id}", session_id)
|
39
|
+
next
|
40
|
+
end
|
41
|
+
channel_array << "hyper-record-update-channel-#{session_id}"
|
42
|
+
end
|
43
|
+
if Hyperloop.resource_transport == :pusher && channel_array.size > 0
|
44
|
+
_pusher_client.trigger_async(channel_array, 'update', message)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
Hyperloop.redis_instance.del("HRPS__#{record.class}__#{record.id}") if record.destroyed?
|
48
|
+
end
|
49
|
+
|
21
50
|
def publish_relation(base_record, relation_name, record = nil)
|
22
51
|
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}")
|
23
52
|
time_now = Time.now.to_f
|
@@ -35,60 +64,40 @@ module HyperRecord
|
|
35
64
|
message[:cause][:updated_at] = record.updated_at
|
36
65
|
message[:cause][:destroyed] = true if record.destroyed?
|
37
66
|
end
|
38
|
-
subscribers.
|
39
|
-
|
40
|
-
|
41
|
-
|
67
|
+
subscribers.each_slice(10) do |slice|
|
68
|
+
channel_array = []
|
69
|
+
slice.each do |session_id, last_requested|
|
70
|
+
if last_requested.to_f < scrub_time
|
71
|
+
Hyperloop.redis_instance.hdel("HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}", session_id)
|
72
|
+
next
|
73
|
+
end
|
74
|
+
channel_array << "hyper-record-update-channel-#{session_id}"
|
42
75
|
end
|
43
76
|
if Hyperloop.resource_transport == :pusher
|
44
|
-
_pusher_client.
|
77
|
+
_pusher_client.trigger_async(channel_array, 'update', message)
|
45
78
|
end
|
46
79
|
end
|
47
80
|
end
|
48
81
|
|
49
|
-
def
|
50
|
-
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{
|
82
|
+
def publish_rest_class_method(record_class, rest_class_method_name)
|
83
|
+
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}")
|
51
84
|
time_now = Time.now.to_f
|
52
85
|
scrub_time = time_now - 24.hours.to_f
|
53
|
-
|
54
86
|
message = {
|
55
|
-
record_type:
|
56
|
-
|
57
|
-
updated_at: record.updated_at
|
87
|
+
record_type: record_class.to_s,
|
88
|
+
rest_class_method: rest_class_method_name
|
58
89
|
}
|
59
|
-
|
60
|
-
|
61
|
-
subscribers.each_slice(50) do |slice|
|
62
|
-
channel_array= []
|
90
|
+
subscribers.each_slice(10) do |slice|
|
91
|
+
channel_array = []
|
63
92
|
slice.each do |session_id, last_requested|
|
64
93
|
if last_requested.to_f < scrub_time
|
65
|
-
Hyperloop.redis_instance.hdel("HRPS__#{
|
94
|
+
Hyperloop.redis_instance.hdel("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}", session_id)
|
66
95
|
next
|
67
96
|
end
|
68
97
|
channel_array << "hyper-record-update-channel-#{session_id}"
|
69
98
|
end
|
70
|
-
if Hyperloop.resource_transport == :pusher && channel_array.size > 0
|
71
|
-
_pusher_client.trigger(channel_array, 'update', message)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
Hyperloop.redis_instance.del("HRPS__#{record.class}__#{record.id}") if record.destroyed?
|
75
|
-
end
|
76
|
-
|
77
|
-
def publish_rest_class_method(record_class, rest_class_method_name)
|
78
|
-
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}")
|
79
|
-
time_now = Time.now.to_f
|
80
|
-
scrub_time = time_now - 24.hours.to_f
|
81
|
-
subscribers.each do |session_id, last_requested|
|
82
|
-
if last_requested.to_f < scrub_time
|
83
|
-
Hyperloop.redis_instance.hdel("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}", session_id)
|
84
|
-
next
|
85
|
-
end
|
86
|
-
message = {
|
87
|
-
record_type: record_class.to_s,
|
88
|
-
rest_class_method: rest_class_method_name
|
89
|
-
}
|
90
99
|
if Hyperloop.resource_transport == :pusher
|
91
|
-
_pusher_client.
|
100
|
+
_pusher_client.trigger_async(channel_array, 'update', message)
|
92
101
|
end
|
93
102
|
end
|
94
103
|
end
|
@@ -97,18 +106,22 @@ module HyperRecord
|
|
97
106
|
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record.class}__#{record.id}__rest_method__#{method_name}")
|
98
107
|
time_now = Time.now.to_f
|
99
108
|
scrub_time = time_now - 24.hours.to_f
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
109
|
+
message = {
|
110
|
+
record_type: record.class.to_s,
|
111
|
+
id: record.id,
|
112
|
+
rest_method: method_name
|
113
|
+
}
|
114
|
+
subscribers.each_slice(10) do |slice|
|
115
|
+
channel_array = []
|
116
|
+
slice.each do |session_id, last_requested|
|
117
|
+
if last_requested.to_f < scrub_time
|
118
|
+
Hyperloop.redis_instance.hdel("HRPS__#{record.class}__#{record.id}__rest_method__#{method_name}", session_id)
|
119
|
+
next
|
120
|
+
end
|
121
|
+
channel_array << "hyper-record-update-channel-#{session_id}"
|
104
122
|
end
|
105
|
-
message = {
|
106
|
-
record_type: record.class.to_s,
|
107
|
-
id: record.id,
|
108
|
-
rest_method: method_name
|
109
|
-
}
|
110
123
|
if Hyperloop.resource_transport == :pusher
|
111
|
-
_pusher_client.
|
124
|
+
_pusher_client.trigger_async(channel_array, 'update', message)
|
112
125
|
end
|
113
126
|
end
|
114
127
|
end
|
@@ -117,21 +130,30 @@ module HyperRecord
|
|
117
130
|
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record_class}__scope__#{scope_name}")
|
118
131
|
time_now = Time.now.to_f
|
119
132
|
scrub_time = time_now - 24.hours.to_f
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
133
|
+
message = {
|
134
|
+
record_type: record_class.to_s,
|
135
|
+
scope: scope_name
|
136
|
+
}
|
137
|
+
subscribers.each_slice(10) do |slice|
|
138
|
+
channel_array = []
|
139
|
+
slice.each do |session_id, last_requested|
|
140
|
+
if last_requested.to_f < scrub_time
|
141
|
+
Hyperloop.redis_instance.hdel("HRPS__#{record_class}__scope__#{scope_name}", session_id)
|
142
|
+
next
|
143
|
+
end
|
144
|
+
channel_array << "hyper-record-update-channel-#{session_id}"
|
124
145
|
end
|
125
|
-
message = {
|
126
|
-
record_type: record_class.to_s,
|
127
|
-
scope: scope_name
|
128
|
-
}
|
129
146
|
if Hyperloop.resource_transport == :pusher
|
130
|
-
_pusher_client.
|
147
|
+
_pusher_client.trigger_async(channel_array, 'update', message)
|
131
148
|
end
|
132
149
|
end
|
133
150
|
end
|
134
151
|
|
152
|
+
def subscribe_record(record)
|
153
|
+
return unless session.id
|
154
|
+
Hyperloop.redis_instance.hset "HRPS__#{record.class}__#{record.id}", session.id.to_s, Time.now.to_f.to_s
|
155
|
+
end
|
156
|
+
|
135
157
|
def subscribe_relation(relation, base_record = nil, relation_name = nil)
|
136
158
|
return unless session.id
|
137
159
|
time_now = Time.now.to_f.to_s
|
@@ -150,11 +172,6 @@ module HyperRecord
|
|
150
172
|
end
|
151
173
|
end
|
152
174
|
|
153
|
-
def subscribe_record(record)
|
154
|
-
return unless session.id
|
155
|
-
Hyperloop.redis_instance.hset "HRPS__#{record.class}__#{record.id}", session.id.to_s, Time.now.to_f.to_s
|
156
|
-
end
|
157
|
-
|
158
175
|
def subscribe_rest_class_method(record_class, rest_class_method_name)
|
159
176
|
return unless session.id
|
160
177
|
time_now = Time.now.to_f.to_s
|
@@ -185,16 +202,16 @@ module HyperRecord
|
|
185
202
|
end
|
186
203
|
end
|
187
204
|
|
188
|
-
def pub_sub_relation(relation, base_record, relation_name, causing_record = nil)
|
189
|
-
subscribe_relation(relation, base_record, relation_name)
|
190
|
-
publish_relation(base_record, relation_name, causing_record)
|
191
|
-
end
|
192
|
-
|
193
205
|
def pub_sub_record(record)
|
194
206
|
subscribe_record(record)
|
195
207
|
publish_record(record)
|
196
208
|
end
|
197
209
|
|
210
|
+
def pub_sub_relation(relation, base_record, relation_name, causing_record = nil)
|
211
|
+
subscribe_relation(relation, base_record, relation_name)
|
212
|
+
publish_relation(base_record, relation_name, causing_record)
|
213
|
+
end
|
214
|
+
|
198
215
|
def pub_sub_rest_class_method(record_class, rest_class_method_name)
|
199
216
|
subscribe_rest_class_method(record_class, rest_class_method_name)
|
200
217
|
publish_rest_class_method(record_class, rest_class_method_name)
|
@@ -217,36 +234,60 @@ module HyperRecord
|
|
217
234
|
|
218
235
|
# instance methods
|
219
236
|
|
237
|
+
def publish_record(record)
|
238
|
+
self.class.publish_record(record)
|
239
|
+
end
|
240
|
+
|
220
241
|
def publish_relation(base_record, relation_name, record = nil)
|
221
242
|
self.class.publish_relation(base_record, relation_name, record)
|
222
243
|
end
|
223
244
|
|
224
|
-
def
|
225
|
-
self.class.
|
245
|
+
def publish_rest_class_method(record_class, rest_class_method_name)
|
246
|
+
self.class.publish_rest_class_method(record_class, rest_class_method_name)
|
247
|
+
end
|
248
|
+
|
249
|
+
def publish_rest_method(record, method_name)
|
250
|
+
self.class.publish_rest_method(record, method_name)
|
226
251
|
end
|
227
252
|
|
228
253
|
def publish_scope(record_class, scope_name)
|
229
254
|
self.class.publish_scope(record_class, scope_name)
|
230
255
|
end
|
231
256
|
|
257
|
+
def subscribe_record(record)
|
258
|
+
self.class.subscribe_record(record)
|
259
|
+
end
|
260
|
+
|
232
261
|
def subscribe_relation(relation, base_record = nil, relation_name = nil)
|
233
262
|
self.class.subscribe_relation(relation, base_record, relation_name)
|
234
263
|
end
|
235
264
|
|
236
|
-
def
|
237
|
-
self.class.
|
265
|
+
def subscribe_rest_class_method(record_class, rest_class_method_name)
|
266
|
+
self.class.subscribe_rest_class_method(record_class, rest_class_method_name)
|
267
|
+
end
|
268
|
+
|
269
|
+
def subscribe_rest_method(record, method_name)
|
270
|
+
self.class.subscribe_rest_method(record, method_name)
|
238
271
|
end
|
239
272
|
|
240
273
|
def subscribe_scope(collection, record_class = nil, scope_name = nil)
|
241
274
|
self.class.subscribe_scope(collection, record_class, scope_name)
|
242
275
|
end
|
243
276
|
|
277
|
+
def pub_sub_record(record)
|
278
|
+
self.class.pub_sub_record(record)
|
279
|
+
end
|
280
|
+
|
244
281
|
def pub_sub_relation(relation, base_record, relation_name, causing_record = nil)
|
245
282
|
self.class.pub_sub_relation(relation, base_record, relation_name, causing_record)
|
246
283
|
end
|
247
284
|
|
248
|
-
def
|
249
|
-
self.class.
|
285
|
+
def pub_sub_rest_class_method(record_class, rest_class_method_name)
|
286
|
+
self.class.pub_sub_rest_class_method(record_class, rest_class_method_name)
|
287
|
+
end
|
288
|
+
|
289
|
+
def pub_sub_rest_method(record, method_name)
|
290
|
+
self.class.pub_sub_rest_method(record, method_name)
|
250
291
|
end
|
251
292
|
|
252
293
|
def pub_sub_scope(collection, record_class, scope_name)
|
@@ -16,6 +16,35 @@ module Hyperloop
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def publish_record(record)
|
20
|
+
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record.class}__#{record.id}")
|
21
|
+
time_now = Time.now.to_f
|
22
|
+
scrub_time = time_now - 24.hours.to_f
|
23
|
+
|
24
|
+
message = {
|
25
|
+
record_type: record.class.to_s,
|
26
|
+
id: record.id,
|
27
|
+
updated_at: record.updated_at
|
28
|
+
}
|
29
|
+
message[:destroyed] = true if record.destroyed?
|
30
|
+
|
31
|
+
# can only trigger to max 10 channels at once on pusher
|
32
|
+
subscribers.each_slice(10) do |slice|
|
33
|
+
channel_array = []
|
34
|
+
slice.each do |session_id, last_requested|
|
35
|
+
if last_requested.to_f < scrub_time
|
36
|
+
Hyperloop.redis_instance.hdel("HRPS__#{record.class}__#{record.id}", session_id)
|
37
|
+
next
|
38
|
+
end
|
39
|
+
channel_array << "hyper-record-update-channel-#{session_id}"
|
40
|
+
end
|
41
|
+
if Hyperloop.resource_transport == :pusher && channel_array.size > 0
|
42
|
+
self.class._pusher_client.trigger_async(channel_array, 'update', message)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
Hyperloop.redis_instance.del("HRPS__#{record.class}__#{record.id}") if record.destroyed?
|
46
|
+
end
|
47
|
+
|
19
48
|
def publish_relation(base_record, relation_name, record = nil)
|
20
49
|
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}")
|
21
50
|
time_now = Time.now.to_f
|
@@ -31,61 +60,42 @@ module Hyperloop
|
|
31
60
|
message[:cause][:record_type] = record.class.to_s
|
32
61
|
message[:cause][:id] = record.id
|
33
62
|
message[:cause][:updated_at] = record.updated_at
|
63
|
+
message[:cause][:destroyed] = true if record.destroyed?
|
34
64
|
end
|
35
|
-
subscribers.
|
36
|
-
|
37
|
-
|
38
|
-
|
65
|
+
subscribers.each_slice(10) do |slice|
|
66
|
+
channel_array = []
|
67
|
+
slice.each do |session_id, last_requested|
|
68
|
+
if last_requested.to_f < scrub_time
|
69
|
+
Hyperloop.redis_instance.hdel("HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}", session_id)
|
70
|
+
next
|
71
|
+
end
|
72
|
+
channel_array << "hyper-record-update-channel-#{session_id}"
|
39
73
|
end
|
40
74
|
if Hyperloop.resource_transport == :pusher
|
41
|
-
self.class._pusher_client.
|
75
|
+
self.class._pusher_client.trigger_async(channel_array, 'update', message)
|
42
76
|
end
|
43
77
|
end
|
44
78
|
end
|
45
79
|
|
46
|
-
def
|
47
|
-
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{
|
80
|
+
def publish_rest_class_method(record_class, rest_class_method_name)
|
81
|
+
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}")
|
48
82
|
time_now = Time.now.to_f
|
49
83
|
scrub_time = time_now - 24.hours.to_f
|
50
|
-
|
51
84
|
message = {
|
52
|
-
record_type:
|
53
|
-
|
54
|
-
updated_at: record.updated_at
|
85
|
+
record_type: record_class.to_s,
|
86
|
+
rest_class_method: rest_class_method_name
|
55
87
|
}
|
56
|
-
|
57
|
-
|
58
|
-
subscribers.each_slice(50) do |slice|
|
59
|
-
channel_array= []
|
88
|
+
subscribers.each_slice(10) do |slice|
|
89
|
+
channel_array = []
|
60
90
|
slice.each do |session_id, last_requested|
|
61
91
|
if last_requested.to_f < scrub_time
|
62
|
-
Hyperloop.redis_instance.hdel("HRPS__#{
|
92
|
+
Hyperloop.redis_instance.hdel("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}", session_id)
|
63
93
|
next
|
64
94
|
end
|
65
95
|
channel_array << "hyper-record-update-channel-#{session_id}"
|
66
96
|
end
|
67
|
-
if Hyperloop.resource_transport == :pusher && channel_array.size > 0
|
68
|
-
self.class._pusher_client.trigger(channel_array, 'update', message)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
Hyperloop.redis_instance.del("HRPS__#{record.class}__#{record.id}") if record.destroyed?
|
72
|
-
end
|
73
|
-
|
74
|
-
def publish_rest_class_method(record_class, rest_class_method_name)
|
75
|
-
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}")
|
76
|
-
time_now = Time.now.to_f
|
77
|
-
scrub_time = time_now - 24.hours.to_f
|
78
|
-
subscribers.each do |session_id, last_requested|
|
79
|
-
if last_requested.to_f < scrub_time
|
80
|
-
Hyperloop.redis_instance.hdel("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}", session_id)
|
81
|
-
next
|
82
|
-
end
|
83
|
-
message = {
|
84
|
-
record_type: record_class.to_s,
|
85
|
-
rest_class_method: rest_class_method_name
|
86
|
-
}
|
87
97
|
if Hyperloop.resource_transport == :pusher
|
88
|
-
self.class._pusher_client.
|
98
|
+
self.class._pusher_client.trigger_async(channel_array, 'update', message)
|
89
99
|
end
|
90
100
|
end
|
91
101
|
end
|
@@ -94,18 +104,22 @@ module Hyperloop
|
|
94
104
|
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record.class}__#{record.id}__rest_method__#{method_name}")
|
95
105
|
time_now = Time.now.to_f
|
96
106
|
scrub_time = time_now - 24.hours.to_f
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
107
|
+
message = {
|
108
|
+
record_type: record.class.to_s,
|
109
|
+
id: record.id,
|
110
|
+
rest_method: method_name
|
111
|
+
}
|
112
|
+
subscribers.each_slice(10) do |slice|
|
113
|
+
channel_array = []
|
114
|
+
slice.each do |session_id, last_requested|
|
115
|
+
if last_requested.to_f < scrub_time
|
116
|
+
Hyperloop.redis_instance.hdel("HRPS__#{record.class}__#{record.id}__rest_method__#{method_name}", session_id)
|
117
|
+
next
|
118
|
+
end
|
119
|
+
channel_array << "hyper-record-update-channel-#{session_id}"
|
101
120
|
end
|
102
|
-
message = {
|
103
|
-
record_type: record.class.to_s,
|
104
|
-
id: record.id,
|
105
|
-
rest_method: method_name
|
106
|
-
}
|
107
121
|
if Hyperloop.resource_transport == :pusher
|
108
|
-
self.class._pusher_client.
|
122
|
+
self.class._pusher_client.trigger_async(channel_array, 'update', message)
|
109
123
|
end
|
110
124
|
end
|
111
125
|
end
|
@@ -114,21 +128,30 @@ module Hyperloop
|
|
114
128
|
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record_class}__scope__#{scope_name}")
|
115
129
|
time_now = Time.now.to_f
|
116
130
|
scrub_time = time_now - 24.hours.to_f
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
131
|
+
message = {
|
132
|
+
record_type: record_class.to_s,
|
133
|
+
scope: scope_name
|
134
|
+
}
|
135
|
+
subscribers.each_slice(10) do |slice|
|
136
|
+
channel_array = []
|
137
|
+
slice.each do |session_id, last_requested|
|
138
|
+
if last_requested.to_f < scrub_time
|
139
|
+
Hyperloop.redis_instance.hdel("HRPS__#{record_class}__scope__#{scope_name}", session_id)
|
140
|
+
next
|
141
|
+
end
|
142
|
+
channel_array << "hyper-record-update-channel-#{session_id}"
|
121
143
|
end
|
122
|
-
message = {
|
123
|
-
record_type: record_class.to_s,
|
124
|
-
scope: scope_name
|
125
|
-
}
|
126
144
|
if Hyperloop.resource_transport == :pusher
|
127
|
-
self.class._pusher_client.
|
145
|
+
self.class._pusher_client.trigger_async(channel_array, 'update', message)
|
128
146
|
end
|
129
147
|
end
|
130
148
|
end
|
131
149
|
|
150
|
+
def subscribe_record(record)
|
151
|
+
return unless session.id
|
152
|
+
Hyperloop.redis_instance.hset "HRPS__#{record.class}__#{record.id}", session.id.to_s, Time.now.to_f.to_s
|
153
|
+
end
|
154
|
+
|
132
155
|
def subscribe_relation(relation, base_record = nil, relation_name = nil)
|
133
156
|
return unless session.id
|
134
157
|
time_now = Time.now.to_f.to_s
|
@@ -147,11 +170,6 @@ module Hyperloop
|
|
147
170
|
end
|
148
171
|
end
|
149
172
|
|
150
|
-
def subscribe_record(record)
|
151
|
-
return unless session.id
|
152
|
-
Hyperloop.redis_instance.hset "HRPS__#{record.class}__#{record.id}", session.id.to_s, Time.now.to_f.to_s
|
153
|
-
end
|
154
|
-
|
155
173
|
def subscribe_rest_class_method(record_class, rest_class_method_name)
|
156
174
|
return unless session.id
|
157
175
|
time_now = Time.now.to_f.to_s
|
@@ -182,16 +200,16 @@ module Hyperloop
|
|
182
200
|
end
|
183
201
|
end
|
184
202
|
|
185
|
-
def pub_sub_relation(relation, base_record, relation_name, causing_record = nil)
|
186
|
-
subscribe_relation(relation, base_record, relation_name)
|
187
|
-
publish_relation(base_record, relation_name, causing_record)
|
188
|
-
end
|
189
|
-
|
190
203
|
def pub_sub_record(record)
|
191
204
|
subscribe_record(record)
|
192
205
|
publish_record(record)
|
193
206
|
end
|
194
207
|
|
208
|
+
def pub_sub_relation(relation, base_record, relation_name, causing_record = nil)
|
209
|
+
subscribe_relation(relation, base_record, relation_name)
|
210
|
+
publish_relation(base_record, relation_name, causing_record)
|
211
|
+
end
|
212
|
+
|
195
213
|
def pub_sub_rest_class_method(record_class, rest_class_method_name)
|
196
214
|
subscribe_rest_class_method(record_class, rest_class_method_name)
|
197
215
|
publish_rest_class_method(record_class, rest_class_method_name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyper-resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.lap77
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|