salesforce_streamer 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/salesforce_streamer/launcher.rb +4 -5
- data/lib/salesforce_streamer/log.rb +13 -0
- data/lib/salesforce_streamer/push_topic.rb +1 -1
- data/lib/salesforce_streamer/replay_persistence.rb +2 -2
- data/lib/salesforce_streamer/server.rb +2 -2
- data/lib/salesforce_streamer/topic_manager.rb +7 -8
- data/lib/salesforce_streamer/version.rb +1 -1
- data/lib/salesforce_streamer.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 155a5949eb2fb6112f66bed9c87ee95b2936dcb29a384cba1e82016aaed9ce7c
|
4
|
+
data.tar.gz: 78f9eda54ef8b075b84446bb80d0f675356a62c3866c7b20dccbafb8480f92f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d86b2c5c246c2ad74ccb6d8201e59c61f211cd8cdf6fdcbe1f16d01ce2ed8641b0256f4058e3a90ea961d95b0cb6bff3fc3bb8e450540c1848c93ff3bd2aa05
|
7
|
+
data.tar.gz: 91c093c56e46853485770e5688767d1eae5b1821984546c9acd8b240b945775981707a0f4411092f455cb3b6f69635bd2e4427e7f100ef05d2d8ffed134233c5
|
@@ -6,7 +6,6 @@ module SalesforceStreamer
|
|
6
6
|
# starting the server.
|
7
7
|
class Launcher
|
8
8
|
def initialize
|
9
|
-
@logger = Configuration.instance.logger
|
10
9
|
load_server_configuration
|
11
10
|
@manager = TopicManager.new push_topics: @push_topics
|
12
11
|
@server = Server.new push_topics: @push_topics
|
@@ -14,7 +13,7 @@ module SalesforceStreamer
|
|
14
13
|
|
15
14
|
# Manages each PushTopic configured and starts the Streaming API listener.
|
16
15
|
def run
|
17
|
-
|
16
|
+
Log.info 'Launching Streamer Services'
|
18
17
|
@manager.run
|
19
18
|
@server.push_topics = @manager.push_topics
|
20
19
|
@server.run
|
@@ -29,16 +28,16 @@ module SalesforceStreamer
|
|
29
28
|
|
30
29
|
def require_application
|
31
30
|
if Configuration.instance.require_path
|
32
|
-
|
31
|
+
Log.debug 'Loading the require path'
|
33
32
|
require Configuration.instance.require_path
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
37
36
|
def initialize_push_topics
|
38
|
-
|
37
|
+
Log.debug 'Loading and validating PushTopics configuration'
|
39
38
|
@push_topics = []
|
40
39
|
Configuration.instance.push_topic_data.values.each do |topic_data|
|
41
|
-
|
40
|
+
Log.debug topic_data.to_s
|
42
41
|
@push_topics << PushTopic.new(data: topic_data)
|
43
42
|
end
|
44
43
|
end
|
@@ -20,7 +20,7 @@ module SalesforceStreamer
|
|
20
20
|
|
21
21
|
def replay
|
22
22
|
@replay ||= (ReplayPersistence.retrieve(name) || @static_replay).tap do |replayId|
|
23
|
-
|
23
|
+
Log.info "PushTopic name=#{name} starting at replayId=#{replayId}"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -6,13 +6,13 @@ module SalesforceStreamer
|
|
6
6
|
class ReplayPersistence
|
7
7
|
class << self
|
8
8
|
def record(key, value)
|
9
|
-
|
9
|
+
Log.debug { "Recording #{key}=value" }
|
10
10
|
Configuration.instance.persistence_adapter&.record key, value
|
11
11
|
end
|
12
12
|
|
13
13
|
def retrieve(key)
|
14
14
|
Configuration.instance.persistence_adapter&.retrieve(key).tap do |v|
|
15
|
-
|
15
|
+
Log.debug { "Retrieved for #{key} #{ v || 'nil' }" }
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -5,14 +5,13 @@ module SalesforceStreamer
|
|
5
5
|
attr_writer :push_topics
|
6
6
|
|
7
7
|
def initialize(push_topics: [])
|
8
|
-
@logger = Configuration.instance.logger
|
9
8
|
@push_topics = push_topics
|
10
9
|
@client = Restforce.new
|
11
10
|
end
|
12
11
|
|
13
12
|
def run
|
14
13
|
@client.authenticate!
|
15
|
-
|
14
|
+
Log.info 'Starting Server'
|
16
15
|
catch_signals
|
17
16
|
start_em
|
18
17
|
end
|
@@ -32,6 +31,7 @@ module SalesforceStreamer
|
|
32
31
|
EM.run do
|
33
32
|
@push_topics.map do |topic|
|
34
33
|
@client.subscribe topic.name, replay: topic.replay.to_i do |msg|
|
34
|
+
Log.info "Message received from topic #{topic.name}"
|
35
35
|
MessageReceiver.call topic.name, topic.handler_constant, msg
|
36
36
|
end
|
37
37
|
end
|
@@ -6,14 +6,13 @@ module SalesforceStreamer
|
|
6
6
|
|
7
7
|
def initialize(push_topics:)
|
8
8
|
@push_topics = push_topics
|
9
|
-
@logger = Configuration.instance.logger
|
10
9
|
@client = SalesforceClient.new
|
11
10
|
end
|
12
11
|
|
13
12
|
def run
|
14
|
-
|
13
|
+
Log.info 'Running Topic Manager'
|
15
14
|
@push_topics.each do |push_topic|
|
16
|
-
|
15
|
+
Log.debug push_topic.to_s
|
17
16
|
upsert(push_topic) if diff?(push_topic)
|
18
17
|
end
|
19
18
|
end
|
@@ -23,25 +22,25 @@ module SalesforceStreamer
|
|
23
22
|
def diff?(push_topic)
|
24
23
|
hashie = @client.find_push_topic_by_name(push_topic.name)
|
25
24
|
unless hashie
|
26
|
-
|
25
|
+
Log.info "New PushTopic #{push_topic.name}"
|
27
26
|
return true
|
28
27
|
end
|
29
|
-
|
28
|
+
Log.debug "Remote PushTopic found with hash=#{hashie.to_h}"
|
30
29
|
push_topic.id = hashie.Id
|
31
30
|
return true unless push_topic.query.eql?(hashie.Query)
|
32
31
|
return true unless push_topic.notify_for_fields.eql?(hashie.NotifyForFields)
|
33
32
|
return true unless push_topic.api_version.to_s.eql?(hashie.ApiVersion.to_s)
|
34
33
|
|
35
|
-
|
34
|
+
Log.debug 'No differences detected'
|
36
35
|
false
|
37
36
|
end
|
38
37
|
|
39
38
|
def upsert(push_topic)
|
40
|
-
|
39
|
+
Log.info "Upsert PushTopic #{push_topic.name}"
|
41
40
|
if Configuration.instance.manage_topics?
|
42
41
|
@client.upsert_push_topic(push_topic)
|
43
42
|
else
|
44
|
-
|
43
|
+
Log.info 'Skipping upsert because manage topics is off'
|
45
44
|
end
|
46
45
|
end
|
47
46
|
end
|
data/lib/salesforce_streamer.rb
CHANGED
@@ -5,9 +5,11 @@ require 'logger'
|
|
5
5
|
require 'optparse'
|
6
6
|
require 'restforce'
|
7
7
|
require 'yaml'
|
8
|
+
require 'forwardable'
|
8
9
|
|
9
10
|
require 'salesforce_streamer/configuration'
|
10
11
|
require 'salesforce_streamer/errors'
|
12
|
+
require 'salesforce_streamer/log'
|
11
13
|
require 'salesforce_streamer/push_topic'
|
12
14
|
require 'salesforce_streamer/topic_manager'
|
13
15
|
require 'salesforce_streamer/salesforce_client'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salesforce_streamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Serok
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- lib/salesforce_streamer/configuration.rb
|
135
135
|
- lib/salesforce_streamer/errors.rb
|
136
136
|
- lib/salesforce_streamer/launcher.rb
|
137
|
+
- lib/salesforce_streamer/log.rb
|
137
138
|
- lib/salesforce_streamer/message_receiver.rb
|
138
139
|
- lib/salesforce_streamer/push_topic.rb
|
139
140
|
- lib/salesforce_streamer/redis_replay.rb
|