salesforce_streamer 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +16 -1
- data/lib/salesforce_streamer/server.rb +19 -14
- data/lib/salesforce_streamer/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: 76475a30dc6515e8071504a9383c2811fa339f0885be703929008aaf2abbed8d
|
4
|
+
data.tar.gz: 927f5ff453fc8e51adaeae3915ee4ace4b0bcf11e355fc66c5aa32dbb5eec3aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf695ae8cf24912b2ccb403b46b3151cc9ec988202ed9dd04857dab27cbef4d9afec3425898384649bc1c5bc84e5a68d515237b20f0b0a249ebe92251d51cebf
|
7
|
+
data.tar.gz: 0b36d256fdc82499c701aa619205c0dddf3d8837200c1e1575f144fd87caed132658e3137d3c3bc9d655157086a5e6fa2b805561729b7cef50e19a526265ef1d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -183,8 +183,23 @@ out more about extensions from
|
|
183
183
|
specs.
|
184
184
|
|
185
185
|
Any configured extensions are added to the Faye client used by the Restforce
|
186
|
-
client when starting up the server.
|
186
|
+
client when starting up the server. If the extension responds to `.server=` then
|
187
|
+
the instance of `SalesforceStreamer::Server` is assigned. This may be convenient
|
188
|
+
to restart the server subscriptions if an error requires a reset.
|
187
189
|
|
190
|
+
```ruby
|
191
|
+
class MyRestartFayeExtension
|
192
|
+
attr_accessor :server
|
193
|
+
|
194
|
+
def incoming(message, callback)
|
195
|
+
callback.call(message).tap |message|
|
196
|
+
server.restart if message['error'] == 'tragic'
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
SalesforceStreamer.config.use_faye_extension MyRestartFayeExtension.new
|
202
|
+
```
|
188
203
|
## Development
|
189
204
|
|
190
205
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -1,15 +1,23 @@
|
|
1
1
|
module SalesforceStreamer
|
2
2
|
class Server
|
3
3
|
attr_writer :push_topics
|
4
|
+
attr_reader :client
|
4
5
|
|
5
6
|
def initialize(push_topics: [])
|
6
7
|
@push_topics = push_topics
|
7
8
|
end
|
8
9
|
|
9
10
|
def run
|
10
|
-
Log.info 'Starting
|
11
|
+
Log.info 'Starting server'
|
11
12
|
catch_signals
|
12
|
-
|
13
|
+
reset_client
|
14
|
+
EM.run { subscribe }
|
15
|
+
end
|
16
|
+
|
17
|
+
def restart
|
18
|
+
Log.info 'Restarting server'
|
19
|
+
reset_client
|
20
|
+
EM.next_tick { subscribe }
|
13
21
|
end
|
14
22
|
|
15
23
|
private
|
@@ -23,24 +31,21 @@ module SalesforceStreamer
|
|
23
31
|
end
|
24
32
|
end
|
25
33
|
|
26
|
-
def
|
27
|
-
return @client if @client
|
34
|
+
def reset_client
|
28
35
|
@client = Restforce.new
|
29
|
-
|
36
|
+
client.authenticate!
|
30
37
|
Configuration.instance.faye_extensions.each do |extension|
|
31
38
|
Log.debug %(adding Faye extension #{extension})
|
32
|
-
|
39
|
+
extension.server = self if extension.respond_to?(:server=)
|
40
|
+
client.faye.add_extension extension
|
33
41
|
end
|
34
|
-
@client
|
35
42
|
end
|
36
43
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
topic.handle message
|
43
|
-
end
|
44
|
+
def subscribe
|
45
|
+
@push_topics.each do |topic|
|
46
|
+
client.subscribe topic.name, replay: Configuration.instance.replay_adapter do |message|
|
47
|
+
Log.info "Message #{message.dig('event', 'replayId')} received from topic #{topic.name}"
|
48
|
+
topic.handle message
|
44
49
|
end
|
45
50
|
end
|
46
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salesforce_streamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Serok
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-11-
|
12
|
+
date: 2020-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dry-initializer
|