salesforce_streamer 2.1.1 → 2.5.0
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/.bundler-version +1 -0
- data/.dependabot/config.yml +7 -2
- data/.github/workflows/auto-approve.yml +3 -3
- data/.github/workflows/auto-merge.yml +19 -0
- data/.travis.yml +1 -1
- data/Gemfile.lock +72 -51
- data/README.md +27 -0
- data/lib/core_extensions/cookiejar/cookie_validation.rb +59 -17
- data/lib/salesforce_streamer/configuration.rb +7 -1
- data/lib/salesforce_streamer/launcher.rb +1 -1
- data/lib/salesforce_streamer/push_topic.rb +5 -5
- data/lib/salesforce_streamer/replay_id_error_extension.rb +1 -1
- data/lib/salesforce_streamer/server.rb +22 -14
- data/lib/salesforce_streamer/version.rb +1 -1
- data/salesforce_streamer.gemspec +6 -2
- metadata +37 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ee0a8f25e58071aab321354f7a419407d70f764c50c84999406dc20d798df147
|
|
4
|
+
data.tar.gz: 3ba160a1abe2748d2bd54191a36a84de8839f4f590654ef71250fdb59172fe42
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 04e3729da95d7ab24d3d4ca76f37323fdaecf5dcdcd825d8dbae03fa183126fa5b919f9eb6602e3cf2815700ae1b7479638c850c2628acfe9e9932111c3933bf
|
|
7
|
+
data.tar.gz: af5151cc9d9d38af500085077328afa77a6d63c6786039e29b32942ebafa76074ee67c005bc3aa38d70cefc1bf79c471838c25e62660fc9445fc7b1ddfb3a451
|
data/.bundler-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.2.22
|
data/.dependabot/config.yml
CHANGED
|
@@ -3,9 +3,14 @@ version: 1
|
|
|
3
3
|
update_configs:
|
|
4
4
|
- package_manager: "ruby:bundler"
|
|
5
5
|
directory: "/"
|
|
6
|
-
update_schedule: "
|
|
6
|
+
update_schedule: "daily"
|
|
7
7
|
commit_message:
|
|
8
8
|
prefix: "[dependabot]"
|
|
9
9
|
allowed_updates:
|
|
10
10
|
- match:
|
|
11
|
-
|
|
11
|
+
dependency_type: "all"
|
|
12
|
+
update_type: "security"
|
|
13
|
+
automerged_updates:
|
|
14
|
+
- match:
|
|
15
|
+
dependency_type: "all"
|
|
16
|
+
update_type: "security:patch"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# automatically approve PRs submitted by Dependabot
|
|
1
|
+
# automatically approve PRs submitted by Dependabot or Renofidev
|
|
2
2
|
# this will allow Dependabot to automatically merge dependency update PRs where CI passes
|
|
3
3
|
# from: https://github.com/hmarr/auto-approve-action
|
|
4
|
-
name: Auto approve
|
|
4
|
+
name: Auto approve dependency upgrades PRs
|
|
5
5
|
|
|
6
6
|
on:
|
|
7
7
|
pull_request
|
|
@@ -11,6 +11,6 @@ jobs:
|
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
steps:
|
|
13
13
|
- uses: hmarr/auto-approve-action@v2.0.0
|
|
14
|
-
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
|
|
14
|
+
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' || github.actor == 'renofidev'
|
|
15
15
|
with:
|
|
16
16
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: automerge
|
|
2
|
+
on:
|
|
3
|
+
pull_request_review:
|
|
4
|
+
types:
|
|
5
|
+
- submitted
|
|
6
|
+
check_suite:
|
|
7
|
+
types:
|
|
8
|
+
- completed
|
|
9
|
+
status: {}
|
|
10
|
+
jobs:
|
|
11
|
+
automerge:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- name: automerge
|
|
15
|
+
uses: "pascalgn/automerge-action@v0.12.0"
|
|
16
|
+
env:
|
|
17
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
18
|
+
MERGE_METHOD: squash
|
|
19
|
+
MERGE_DELETE_BRANCH: true
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
salesforce_streamer (2.
|
|
4
|
+
salesforce_streamer (2.5.0)
|
|
5
|
+
cookiejar (~> 0.3.0)
|
|
5
6
|
dry-initializer (~> 3.0)
|
|
7
|
+
eventmachine (~> 1.2)
|
|
6
8
|
faye (~> 1.4)
|
|
7
|
-
restforce (
|
|
9
|
+
restforce (~> 5.0)
|
|
8
10
|
|
|
9
11
|
GEM
|
|
10
12
|
remote: https://rubygems.org/
|
|
11
13
|
specs:
|
|
12
|
-
addressable (2.
|
|
14
|
+
addressable (2.8.0)
|
|
13
15
|
public_suffix (>= 2.0.2, < 5.0)
|
|
14
|
-
ast (2.4.
|
|
16
|
+
ast (2.4.2)
|
|
15
17
|
byebug (11.1.3)
|
|
16
|
-
codecov (0.2
|
|
17
|
-
|
|
18
|
-
simplecov
|
|
18
|
+
codecov (0.5.2)
|
|
19
|
+
simplecov (>= 0.15, < 0.22)
|
|
19
20
|
cookiejar (0.3.3)
|
|
20
21
|
diff-lcs (1.4.4)
|
|
21
|
-
docile (1.
|
|
22
|
-
dry-initializer (3.0.
|
|
22
|
+
docile (1.4.0)
|
|
23
|
+
dry-initializer (3.0.4)
|
|
23
24
|
em-http-request (1.1.7)
|
|
24
25
|
addressable (>= 2.3.4)
|
|
25
26
|
cookiejar (!= 0.3.1)
|
|
@@ -29,8 +30,23 @@ GEM
|
|
|
29
30
|
em-socksify (0.3.2)
|
|
30
31
|
eventmachine (>= 1.0.0.beta.4)
|
|
31
32
|
eventmachine (1.2.7)
|
|
32
|
-
faraday (1.0
|
|
33
|
+
faraday (1.5.0)
|
|
34
|
+
faraday-em_http (~> 1.0)
|
|
35
|
+
faraday-em_synchrony (~> 1.0)
|
|
36
|
+
faraday-excon (~> 1.1)
|
|
37
|
+
faraday-httpclient (~> 1.0.1)
|
|
38
|
+
faraday-net_http (~> 1.0)
|
|
39
|
+
faraday-net_http_persistent (~> 1.1)
|
|
40
|
+
faraday-patron (~> 1.0)
|
|
33
41
|
multipart-post (>= 1.2, < 3)
|
|
42
|
+
ruby2_keywords (>= 0.0.4)
|
|
43
|
+
faraday-em_http (1.0.0)
|
|
44
|
+
faraday-em_synchrony (1.0.0)
|
|
45
|
+
faraday-excon (1.1.0)
|
|
46
|
+
faraday-httpclient (1.0.1)
|
|
47
|
+
faraday-net_http (1.0.1)
|
|
48
|
+
faraday-net_http_persistent (1.1.0)
|
|
49
|
+
faraday-patron (1.0.0)
|
|
34
50
|
faraday_middleware (1.0.0)
|
|
35
51
|
faraday (~> 1.0)
|
|
36
52
|
faye (1.4.0)
|
|
@@ -41,69 +57,74 @@ GEM
|
|
|
41
57
|
multi_json (>= 1.0.0)
|
|
42
58
|
rack (>= 1.0.0)
|
|
43
59
|
websocket-driver (>= 0.5.1)
|
|
44
|
-
faye-websocket (0.11.
|
|
60
|
+
faye-websocket (0.11.1)
|
|
45
61
|
eventmachine (>= 0.12.0)
|
|
46
62
|
websocket-driver (>= 0.5.1)
|
|
47
63
|
hashie (4.1.0)
|
|
48
|
-
http_parser.rb (0.
|
|
49
|
-
|
|
50
|
-
jwt (2.2.2)
|
|
64
|
+
http_parser.rb (0.7.0)
|
|
65
|
+
jwt (2.2.3)
|
|
51
66
|
multi_json (1.15.0)
|
|
52
67
|
multipart-post (2.1.1)
|
|
53
|
-
parallel (1.
|
|
54
|
-
parser (
|
|
68
|
+
parallel (1.20.1)
|
|
69
|
+
parser (3.0.1.1)
|
|
55
70
|
ast (~> 2.4.1)
|
|
56
|
-
public_suffix (4.0.
|
|
71
|
+
public_suffix (4.0.6)
|
|
57
72
|
rack (2.2.3)
|
|
58
73
|
rainbow (3.0.0)
|
|
59
|
-
rake (13.0.
|
|
60
|
-
regexp_parser (1.
|
|
61
|
-
restforce (5.0.
|
|
74
|
+
rake (13.0.4)
|
|
75
|
+
regexp_parser (2.1.1)
|
|
76
|
+
restforce (5.0.6)
|
|
62
77
|
faraday (>= 0.9.0, <= 2.0)
|
|
63
78
|
faraday_middleware (>= 0.8.8, <= 2.0)
|
|
64
79
|
hashie (>= 1.2.0, < 5.0)
|
|
65
80
|
jwt (>= 1.5.6)
|
|
66
|
-
rexml (3.2.
|
|
67
|
-
rspec (3.
|
|
68
|
-
rspec-core (~> 3.
|
|
69
|
-
rspec-expectations (~> 3.
|
|
70
|
-
rspec-mocks (~> 3.
|
|
71
|
-
rspec-core (3.
|
|
72
|
-
rspec-support (~> 3.
|
|
73
|
-
rspec-expectations (3.
|
|
81
|
+
rexml (3.2.5)
|
|
82
|
+
rspec (3.10.0)
|
|
83
|
+
rspec-core (~> 3.10.0)
|
|
84
|
+
rspec-expectations (~> 3.10.0)
|
|
85
|
+
rspec-mocks (~> 3.10.0)
|
|
86
|
+
rspec-core (3.10.1)
|
|
87
|
+
rspec-support (~> 3.10.0)
|
|
88
|
+
rspec-expectations (3.10.1)
|
|
74
89
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
75
|
-
rspec-support (~> 3.
|
|
76
|
-
rspec-mocks (3.
|
|
90
|
+
rspec-support (~> 3.10.0)
|
|
91
|
+
rspec-mocks (3.10.2)
|
|
77
92
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
78
|
-
rspec-support (~> 3.
|
|
79
|
-
rspec-support (3.
|
|
80
|
-
rubocop (
|
|
93
|
+
rspec-support (~> 3.10.0)
|
|
94
|
+
rspec-support (3.10.2)
|
|
95
|
+
rubocop (1.18.3)
|
|
81
96
|
parallel (~> 1.10)
|
|
82
|
-
parser (>=
|
|
97
|
+
parser (>= 3.0.0.0)
|
|
83
98
|
rainbow (>= 2.2.2, < 4.0)
|
|
84
|
-
regexp_parser (>= 1.
|
|
99
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
85
100
|
rexml
|
|
86
|
-
rubocop-ast (>=
|
|
101
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
|
87
102
|
ruby-progressbar (~> 1.7)
|
|
88
|
-
unicode-display_width (>= 1.4.0, <
|
|
89
|
-
rubocop-ast (
|
|
90
|
-
parser (>=
|
|
91
|
-
rubocop-
|
|
92
|
-
rubocop (
|
|
93
|
-
rubocop-rspec (
|
|
94
|
-
rubocop (~> 0
|
|
95
|
-
|
|
96
|
-
|
|
103
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
104
|
+
rubocop-ast (1.7.0)
|
|
105
|
+
parser (>= 3.0.1.1)
|
|
106
|
+
rubocop-rake (0.6.0)
|
|
107
|
+
rubocop (~> 1.0)
|
|
108
|
+
rubocop-rspec (2.4.0)
|
|
109
|
+
rubocop (~> 1.0)
|
|
110
|
+
rubocop-ast (>= 1.1.0)
|
|
111
|
+
ruby-progressbar (1.11.0)
|
|
112
|
+
ruby2_keywords (0.0.4)
|
|
113
|
+
simplecov (0.21.2)
|
|
97
114
|
docile (~> 1.1)
|
|
98
115
|
simplecov-html (~> 0.11)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
simplecov_json_formatter (~> 0.1)
|
|
117
|
+
simplecov-html (0.12.3)
|
|
118
|
+
simplecov_json_formatter (0.1.3)
|
|
119
|
+
unicode-display_width (2.0.0)
|
|
120
|
+
websocket-driver (0.7.5)
|
|
102
121
|
websocket-extensions (>= 0.1.0)
|
|
103
122
|
websocket-extensions (0.1.5)
|
|
104
123
|
|
|
105
124
|
PLATFORMS
|
|
106
|
-
|
|
125
|
+
x86_64-darwin-19
|
|
126
|
+
x86_64-darwin-20
|
|
127
|
+
x86_64-linux
|
|
107
128
|
|
|
108
129
|
DEPENDENCIES
|
|
109
130
|
byebug
|
|
@@ -111,9 +132,9 @@ DEPENDENCIES
|
|
|
111
132
|
rake
|
|
112
133
|
rspec
|
|
113
134
|
rubocop
|
|
114
|
-
rubocop-
|
|
135
|
+
rubocop-rake
|
|
115
136
|
rubocop-rspec
|
|
116
137
|
salesforce_streamer!
|
|
117
138
|
|
|
118
139
|
BUNDLED WITH
|
|
119
|
-
2.
|
|
140
|
+
2.2.22
|
data/README.md
CHANGED
|
@@ -91,6 +91,7 @@ SalesforceStreamer.configure do |config|
|
|
|
91
91
|
config.exception_adapter = proc { |e| puts e }
|
|
92
92
|
config.replay_adapter = MyReplayAdapter
|
|
93
93
|
config.use_middleware AfterMessageReceived
|
|
94
|
+
config.use_faye_extension ErrorLoggingExtension.new
|
|
94
95
|
config.manage_topics = true
|
|
95
96
|
end
|
|
96
97
|
```
|
|
@@ -173,6 +174,32 @@ end
|
|
|
173
174
|
|
|
174
175
|
This adapter will be used directly by `Restforce::ReplayExtension`.
|
|
175
176
|
|
|
177
|
+
### Use Faye Extension
|
|
178
|
+
|
|
179
|
+
The `config.use_faye_extension` should be given an object that responds to
|
|
180
|
+
`.incoming(message, callback)` or `.outgoing(message, callback)` or both. Find
|
|
181
|
+
out more about extensions from
|
|
182
|
+
[Faye](https://github.com/faye/faye/blob/master/spec/ruby/server/extensions_spec.rb)
|
|
183
|
+
specs.
|
|
184
|
+
|
|
185
|
+
Any configured extensions are added to the Faye client used by the Restforce
|
|
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.
|
|
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
|
+
```
|
|
176
203
|
## Development
|
|
177
204
|
|
|
178
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,27 +1,69 @@
|
|
|
1
|
+
require 'cookiejar/cookie_validation'
|
|
2
|
+
|
|
1
3
|
# Original source code at
|
|
2
4
|
# https://github.com/dwaite/cookiejar/blob/master/lib/cookiejar/cookie_validation.rb
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
module CookieJar
|
|
6
|
+
module CookieValidation
|
|
7
|
+
# Re-opening the CookieValidation module to rewrite the domains_match method to
|
|
8
|
+
# skip the validation of domains. Open issue at
|
|
9
|
+
# https://github.com/restforce/restforce/issues/120
|
|
10
|
+
def self.domains_match(tested_domain, base_domain)
|
|
11
|
+
return true if tested_domain[-15..].eql?('.salesforce.com')
|
|
12
|
+
|
|
13
|
+
# original implementation
|
|
14
|
+
base = effective_host base_domain
|
|
15
|
+
search_domains = compute_search_domains_for_host base
|
|
16
|
+
search_domains.find do |domain|
|
|
17
|
+
domain == tested_domain
|
|
18
|
+
end
|
|
19
|
+
end
|
|
13
20
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
# Implements https://github.com/dwaite/cookiejar/commit/adb79c0a14c2b347c5289e79379a1acfe34bf388
|
|
22
|
+
# which is not part of the cookiejar gem yet and is required to prevent
|
|
23
|
+
# Unknown cookie parameter 'samesite' (CookieJar::InvalidCookieError)
|
|
24
|
+
def self.parse_set_cookie(set_cookie_value)
|
|
25
|
+
args = {}
|
|
26
|
+
params = set_cookie_value.split(/;\s*/)
|
|
27
|
+
|
|
28
|
+
first = true
|
|
29
|
+
params.each do |param|
|
|
30
|
+
result = PARAM1.match param
|
|
31
|
+
unless result
|
|
32
|
+
fail InvalidCookieError,
|
|
33
|
+
"Invalid cookie parameter in cookie '#{set_cookie_value}'"
|
|
34
|
+
end
|
|
35
|
+
key = result[1].downcase.to_sym
|
|
36
|
+
keyvalue = result[2]
|
|
37
|
+
if first
|
|
38
|
+
args[:name] = result[1]
|
|
39
|
+
args[:value] = keyvalue
|
|
40
|
+
first = false
|
|
41
|
+
else
|
|
42
|
+
case key
|
|
43
|
+
when :expires
|
|
44
|
+
begin
|
|
45
|
+
args[:expires_at] = Time.parse keyvalue
|
|
46
|
+
rescue ArgumentError
|
|
47
|
+
raise unless $ERROR_INFO.message == 'time out of range'
|
|
48
|
+
args[:expires_at] = Time.at(0x7FFFFFFF)
|
|
19
49
|
end
|
|
50
|
+
when :'max-age'
|
|
51
|
+
args[:max_age] = keyvalue.to_i
|
|
52
|
+
when :domain, :path
|
|
53
|
+
args[key] = keyvalue
|
|
54
|
+
when :secure
|
|
55
|
+
args[:secure] = true
|
|
56
|
+
when :httponly
|
|
57
|
+
args[:http_only] = true
|
|
58
|
+
when :samesite
|
|
59
|
+
args[:samesite] = keyvalue.downcase
|
|
60
|
+
else
|
|
61
|
+
fail InvalidCookieError, "Unknown cookie parameter '#{key}'"
|
|
20
62
|
end
|
|
21
63
|
end
|
|
22
64
|
end
|
|
65
|
+
args[:version] = 0
|
|
66
|
+
args
|
|
23
67
|
end
|
|
24
68
|
end
|
|
25
69
|
end
|
|
26
|
-
|
|
27
|
-
CookieJar::CookieValidation.extend(CoreExtensions::CookieJar::CookieValidation)
|
|
@@ -3,7 +3,7 @@ module SalesforceStreamer
|
|
|
3
3
|
class Configuration
|
|
4
4
|
attr_accessor :environment, :logger, :require_path, :config_file,
|
|
5
5
|
:manage_topics, :exception_adapter, :replay_adapter
|
|
6
|
-
attr_reader :middleware
|
|
6
|
+
attr_reader :middleware, :faye_extensions
|
|
7
7
|
|
|
8
8
|
class << self
|
|
9
9
|
attr_writer :instance
|
|
@@ -26,6 +26,7 @@ module SalesforceStreamer
|
|
|
26
26
|
@config_file = './config/streamer.yml'
|
|
27
27
|
@require_path = './config/environment'
|
|
28
28
|
@middleware = []
|
|
29
|
+
@faye_extensions = [ReplayIdErrorExtension.new]
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
def manage_topics?
|
|
@@ -37,6 +38,11 @@ module SalesforceStreamer
|
|
|
37
38
|
@middleware << [klass, args, block]
|
|
38
39
|
end
|
|
39
40
|
|
|
41
|
+
# adds a Faye extension
|
|
42
|
+
def use_faye_extension(extension)
|
|
43
|
+
@faye_extensions << extension
|
|
44
|
+
end
|
|
45
|
+
|
|
40
46
|
# returns a ready to use chain of middleware
|
|
41
47
|
def middleware_runner(last_handler)
|
|
42
48
|
@middleware.reduce(last_handler) do |next_handler, current_handler|
|
|
@@ -36,7 +36,7 @@ module SalesforceStreamer
|
|
|
36
36
|
@push_topics = []
|
|
37
37
|
Configuration.instance.push_topic_data.each_value do |topic_data|
|
|
38
38
|
Log.debug topic_data.to_s
|
|
39
|
-
@push_topics << PushTopic.new(topic_data.transform_keys(&:to_sym))
|
|
39
|
+
@push_topics << PushTopic.new(**topic_data.transform_keys(&:to_sym))
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
end
|
|
@@ -4,11 +4,11 @@ module SalesforceStreamer
|
|
|
4
4
|
extend Dry::Initializer
|
|
5
5
|
|
|
6
6
|
option :name
|
|
7
|
-
option :query,
|
|
8
|
-
option :handler,
|
|
9
|
-
option :replay,
|
|
10
|
-
option :api_version, proc(&:to_s), default:
|
|
11
|
-
option :notify_for_fields, default:
|
|
7
|
+
option :query, ->(v) { v.gsub(/\s+/, ' ') }
|
|
8
|
+
option :handler, ->(v) { prepare_handler_proc(Object.const_get(v)) }
|
|
9
|
+
option :replay, ->(v) { v.to_i }, default: -> { -1 }
|
|
10
|
+
option :api_version, proc(&:to_s), default: -> { '49.0' }
|
|
11
|
+
option :notify_for_fields, default: -> { 'Referenced' }
|
|
12
12
|
option :id, optional: true
|
|
13
13
|
option :description, optional: true
|
|
14
14
|
|
|
@@ -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,21 +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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
client.authenticate!
|
|
37
|
+
Configuration.instance.faye_extensions.each do |extension|
|
|
38
|
+
Log.debug %(adding Faye extension #{extension})
|
|
39
|
+
extension.server = self if extension.respond_to?(:server=)
|
|
40
|
+
client.faye.add_extension extension
|
|
41
|
+
end
|
|
32
42
|
end
|
|
33
43
|
|
|
34
|
-
def
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
topic.handle message
|
|
40
|
-
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
|
|
41
49
|
end
|
|
42
50
|
end
|
|
43
51
|
end
|
data/salesforce_streamer.gemspec
CHANGED
|
@@ -25,15 +25,19 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
|
|
26
26
|
spec.required_ruby_version = '>= 2.6'
|
|
27
27
|
|
|
28
|
+
spec.add_dependency 'cookiejar', '~> 0.3.0'
|
|
28
29
|
spec.add_dependency 'dry-initializer', '~> 3.0'
|
|
29
30
|
spec.add_dependency 'faye', '~> 1.4'
|
|
30
|
-
spec.add_dependency 'restforce', '
|
|
31
|
+
spec.add_dependency 'restforce', '~> 5.0'
|
|
32
|
+
# # When you have issues installing eventmachine on osx and ruby 3, try:
|
|
33
|
+
# gem install eventmachine -- --with-openssl-dir=/usr/local/opt/openssl@1.1
|
|
34
|
+
spec.add_dependency 'eventmachine', '~> 1.2'
|
|
31
35
|
|
|
32
36
|
spec.add_development_dependency 'byebug'
|
|
33
37
|
spec.add_development_dependency 'codecov'
|
|
34
38
|
spec.add_development_dependency 'rake'
|
|
35
39
|
spec.add_development_dependency 'rspec'
|
|
36
40
|
spec.add_development_dependency 'rubocop'
|
|
37
|
-
spec.add_development_dependency 'rubocop-
|
|
41
|
+
spec.add_development_dependency 'rubocop-rake'
|
|
38
42
|
spec.add_development_dependency 'rubocop-rspec'
|
|
39
43
|
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.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Scott Serok
|
|
@@ -9,8 +9,22 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2021-07-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: cookiejar
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - "~>"
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: 0.3.0
|
|
21
|
+
type: :runtime
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - "~>"
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: 0.3.0
|
|
14
28
|
- !ruby/object:Gem::Dependency
|
|
15
29
|
name: dry-initializer
|
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -43,22 +57,30 @@ dependencies:
|
|
|
43
57
|
name: restforce
|
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
|
45
59
|
requirements:
|
|
46
|
-
- - "
|
|
47
|
-
- !ruby/object:Gem::Version
|
|
48
|
-
version: '4.2'
|
|
49
|
-
- - "<"
|
|
60
|
+
- - "~>"
|
|
50
61
|
- !ruby/object:Gem::Version
|
|
51
|
-
version: '
|
|
62
|
+
version: '5.0'
|
|
52
63
|
type: :runtime
|
|
53
64
|
prerelease: false
|
|
54
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
55
66
|
requirements:
|
|
56
|
-
- - "
|
|
67
|
+
- - "~>"
|
|
57
68
|
- !ruby/object:Gem::Version
|
|
58
|
-
version: '
|
|
59
|
-
|
|
69
|
+
version: '5.0'
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: eventmachine
|
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - "~>"
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '1.2'
|
|
77
|
+
type: :runtime
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - "~>"
|
|
60
82
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
83
|
+
version: '1.2'
|
|
62
84
|
- !ruby/object:Gem::Dependency
|
|
63
85
|
name: byebug
|
|
64
86
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -130,7 +152,7 @@ dependencies:
|
|
|
130
152
|
- !ruby/object:Gem::Version
|
|
131
153
|
version: '0'
|
|
132
154
|
- !ruby/object:Gem::Dependency
|
|
133
|
-
name: rubocop-
|
|
155
|
+
name: rubocop-rake
|
|
134
156
|
requirement: !ruby/object:Gem::Requirement
|
|
135
157
|
requirements:
|
|
136
158
|
- - ">="
|
|
@@ -166,12 +188,14 @@ executables:
|
|
|
166
188
|
extensions: []
|
|
167
189
|
extra_rdoc_files: []
|
|
168
190
|
files:
|
|
191
|
+
- ".bundler-version"
|
|
169
192
|
- ".dependabot/config.yml"
|
|
170
193
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
|
171
194
|
- ".github/ISSUE_TEMPLATE/config.yml"
|
|
172
195
|
- ".github/ISSUE_TEMPLATE/story.md"
|
|
173
196
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
|
174
197
|
- ".github/workflows/auto-approve.yml"
|
|
198
|
+
- ".github/workflows/auto-merge.yml"
|
|
175
199
|
- ".gitignore"
|
|
176
200
|
- ".rspec"
|
|
177
201
|
- ".travis.yml"
|
|
@@ -218,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
218
242
|
- !ruby/object:Gem::Version
|
|
219
243
|
version: '0'
|
|
220
244
|
requirements: []
|
|
221
|
-
rubygems_version: 3.
|
|
245
|
+
rubygems_version: 3.2.15
|
|
222
246
|
signing_key:
|
|
223
247
|
specification_version: 4
|
|
224
248
|
summary: A wrapper around the Restforce Streaming API with a built-in PushTopic manager.
|