salesforce_streamer 1.1.0 → 1.2.2
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/.dependabot/config.yml +18 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
- data/.github/ISSUE_TEMPLATE/config.yml +1 -0
- data/.github/ISSUE_TEMPLATE/story.md +22 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +18 -0
- data/.github/workflows/auto-approve.yml +16 -0
- data/.travis.yml +3 -2
- data/Gemfile.lock +47 -40
- data/README.md +33 -9
- data/Rakefile +1 -1
- data/lib/core_extensions/cookiejar/cookie_validation.rb +1 -1
- data/lib/salesforce_streamer.rb +0 -1
- data/lib/salesforce_streamer/configuration.rb +11 -1
- data/lib/salesforce_streamer/launcher.rb +1 -1
- data/lib/salesforce_streamer/push_topic.rb +27 -6
- data/lib/salesforce_streamer/server.rb +5 -3
- data/lib/salesforce_streamer/version.rb +1 -1
- data/salesforce_streamer.gemspec +12 -11
- metadata +26 -6
- data/CODE_OF_CONDUCT.md +0 -74
- data/lib/salesforce_streamer/message_receiver.rb +0 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 88a8ec9604b29ed48acfcf8ac1435fcacf199a7813eba8db8937038874132128
|
|
4
|
+
data.tar.gz: 5b7c06be3a4467d41845e76578c95a9bb197a10017ee893eb2acc516b26ffbb0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 36d5ba79e4af94533266bc9ac52b5110b6a4f6305db9c60a6498b7218d7a5e8c7f48b9db008b582c56877845bb9a498618141da4af0c3e1b77a8173a0640733d
|
|
7
|
+
data.tar.gz: d06777105574d0ff430888059ab1d1f61164f520da6b3b5a1c6408e983de3fe22d27fabf575e46a2d7f7ce14936e7af8423b8c7b433a296183a73da8716cd0e9
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
|
|
3
|
+
update_configs:
|
|
4
|
+
- package_manager: "ruby:bundler"
|
|
5
|
+
directory: "/"
|
|
6
|
+
update_schedule: "monthly"
|
|
7
|
+
commit_message:
|
|
8
|
+
prefix: "[dependabot]"
|
|
9
|
+
allowed_updates:
|
|
10
|
+
- match:
|
|
11
|
+
update_type: "all"
|
|
12
|
+
automerged_updates:
|
|
13
|
+
- match:
|
|
14
|
+
dependency_type: "development"
|
|
15
|
+
update_type: "all"
|
|
16
|
+
- match:
|
|
17
|
+
dependency_type: "production"
|
|
18
|
+
update_type: "all"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to track an issue that has been identified
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the behavior:
|
|
15
|
+
1. Go to '...'
|
|
16
|
+
2. Click on '....'
|
|
17
|
+
3. Scroll down to '....'
|
|
18
|
+
4. See error
|
|
19
|
+
|
|
20
|
+
**Expected behavior**
|
|
21
|
+
A clear and concise description of what you expected to happen.
|
|
22
|
+
|
|
23
|
+
**Mutation/Query**
|
|
24
|
+
|
|
25
|
+
**URL and HTTP method (for non-GQL):**
|
|
26
|
+
|
|
27
|
+
**Sentry or Logs URL:**
|
|
28
|
+
|
|
29
|
+
**User/authentication details**
|
|
30
|
+
Impacted user name or service account
|
|
31
|
+
|
|
32
|
+
**Additional context**
|
|
33
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
blank_issues_enabled: false
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: New story
|
|
3
|
+
about: Add a new story for implementation
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the solution**
|
|
11
|
+
A clear and concise description of what you want to happen.
|
|
12
|
+
When will this feature be done?
|
|
13
|
+
|
|
14
|
+
**Describe the users**
|
|
15
|
+
Who are we building this feature for?
|
|
16
|
+
|
|
17
|
+
**Additional context**
|
|
18
|
+
Add any other context or screenshots about the feature request here.
|
|
19
|
+
Link to any applicable documents describing the feature.
|
|
20
|
+
|
|
21
|
+
**Designs**
|
|
22
|
+
Link to any applicable designs on Invision.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
## Description
|
|
2
|
+
<!--- Describe your changes in detail -->
|
|
3
|
+
|
|
4
|
+
## Related issue(s)
|
|
5
|
+
<!--- GH issue number -->
|
|
6
|
+
|
|
7
|
+
## Motivation and Context
|
|
8
|
+
<!--- Why is this change required? What problem does it solve? -->
|
|
9
|
+
<!--- If it fixes an open issue, please link to the issue here. -->
|
|
10
|
+
|
|
11
|
+
## How Has This Been Tested?
|
|
12
|
+
<!--- Please describe in detail how you tested your changes. -->
|
|
13
|
+
|
|
14
|
+
## Screenshots (if appropriate):
|
|
15
|
+
<!--- Please add any screenshots of the feature. -->
|
|
16
|
+
|
|
17
|
+
## Related PRs
|
|
18
|
+
<!--- Please add links to any related PRs (backend, component packages, etc). -->
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# automatically approve PRs submitted by Dependabot
|
|
2
|
+
# this will allow Dependabot to automatically merge dependency update PRs where CI passes
|
|
3
|
+
# from: https://github.com/hmarr/auto-approve-action
|
|
4
|
+
name: Auto approve Dependabot PRs
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
pull_request
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
auto-approve:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: hmarr/auto-approve-action@v2.0.0
|
|
14
|
+
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
|
|
15
|
+
with:
|
|
16
|
+
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
salesforce_streamer (1.
|
|
4
|
+
salesforce_streamer (1.2.2)
|
|
5
5
|
faye (= 0.8.9)
|
|
6
6
|
restforce (~> 4.2)
|
|
7
7
|
|
|
@@ -10,16 +10,17 @@ GEM
|
|
|
10
10
|
specs:
|
|
11
11
|
addressable (2.7.0)
|
|
12
12
|
public_suffix (>= 2.0.2, < 5.0)
|
|
13
|
-
ast (2.4.
|
|
14
|
-
byebug (11.
|
|
15
|
-
codecov (0.
|
|
13
|
+
ast (2.4.1)
|
|
14
|
+
byebug (11.1.3)
|
|
15
|
+
codecov (0.2.0)
|
|
16
|
+
colorize
|
|
16
17
|
json
|
|
17
18
|
simplecov
|
|
18
|
-
|
|
19
|
+
colorize (0.8.1)
|
|
19
20
|
cookiejar (0.3.3)
|
|
20
|
-
diff-lcs (1.
|
|
21
|
+
diff-lcs (1.4.4)
|
|
21
22
|
docile (1.3.2)
|
|
22
|
-
em-http-request (1.1.
|
|
23
|
+
em-http-request (1.1.6)
|
|
23
24
|
addressable (>= 2.3.4)
|
|
24
25
|
cookiejar (!= 0.3.1)
|
|
25
26
|
em-socksify (>= 0.3)
|
|
@@ -28,10 +29,10 @@ GEM
|
|
|
28
29
|
em-socksify (0.3.2)
|
|
29
30
|
eventmachine (>= 1.0.0.beta.4)
|
|
30
31
|
eventmachine (1.2.7)
|
|
31
|
-
faraday (0.
|
|
32
|
+
faraday (1.0.0)
|
|
32
33
|
multipart-post (>= 1.2, < 3)
|
|
33
|
-
faraday_middleware (0.
|
|
34
|
-
faraday (
|
|
34
|
+
faraday_middleware (1.0.0)
|
|
35
|
+
faraday (~> 1.0)
|
|
35
36
|
faye (0.8.9)
|
|
36
37
|
cookiejar (>= 0.3.0)
|
|
37
38
|
em-http-request (>= 0.3.0)
|
|
@@ -39,61 +40,66 @@ GEM
|
|
|
39
40
|
faye-websocket (>= 0.4.0)
|
|
40
41
|
rack (>= 1.0.0)
|
|
41
42
|
yajl-ruby (>= 1.0.0)
|
|
42
|
-
faye-websocket (0.
|
|
43
|
+
faye-websocket (0.11.0)
|
|
43
44
|
eventmachine (>= 0.12.0)
|
|
44
45
|
websocket-driver (>= 0.5.1)
|
|
45
|
-
hashie (4.
|
|
46
|
+
hashie (4.1.0)
|
|
46
47
|
http_parser.rb (0.6.0)
|
|
47
|
-
|
|
48
|
-
json (2.3.0)
|
|
48
|
+
json (2.3.1)
|
|
49
49
|
jwt (2.2.1)
|
|
50
50
|
multipart-post (2.1.1)
|
|
51
|
-
parallel (1.19.
|
|
52
|
-
parser (2.
|
|
53
|
-
ast (~> 2.4.
|
|
54
|
-
public_suffix (4.0.
|
|
55
|
-
rack (2.
|
|
51
|
+
parallel (1.19.2)
|
|
52
|
+
parser (2.7.1.4)
|
|
53
|
+
ast (~> 2.4.1)
|
|
54
|
+
public_suffix (4.0.5)
|
|
55
|
+
rack (2.2.3)
|
|
56
56
|
rainbow (3.0.0)
|
|
57
57
|
rake (13.0.1)
|
|
58
|
-
|
|
58
|
+
regexp_parser (1.7.1)
|
|
59
|
+
restforce (4.2.2)
|
|
59
60
|
faraday (>= 0.9.0, <= 1.0)
|
|
60
61
|
faraday_middleware (>= 0.8.8, <= 1.0)
|
|
61
62
|
hashie (>= 1.2.0, < 5.0)
|
|
62
63
|
json (>= 1.7.5)
|
|
63
64
|
jwt (>= 1.5.6)
|
|
65
|
+
rexml (3.2.4)
|
|
64
66
|
rspec (3.9.0)
|
|
65
67
|
rspec-core (~> 3.9.0)
|
|
66
68
|
rspec-expectations (~> 3.9.0)
|
|
67
69
|
rspec-mocks (~> 3.9.0)
|
|
68
|
-
rspec-core (3.9.
|
|
69
|
-
rspec-support (~> 3.9.
|
|
70
|
-
rspec-expectations (3.9.
|
|
70
|
+
rspec-core (3.9.2)
|
|
71
|
+
rspec-support (~> 3.9.3)
|
|
72
|
+
rspec-expectations (3.9.2)
|
|
71
73
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
72
74
|
rspec-support (~> 3.9.0)
|
|
73
|
-
rspec-mocks (3.9.
|
|
75
|
+
rspec-mocks (3.9.1)
|
|
74
76
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
75
77
|
rspec-support (~> 3.9.0)
|
|
76
|
-
rspec-support (3.9.
|
|
77
|
-
rubocop (0.
|
|
78
|
-
jaro_winkler (~> 1.5.1)
|
|
78
|
+
rspec-support (3.9.3)
|
|
79
|
+
rubocop (0.88.0)
|
|
79
80
|
parallel (~> 1.10)
|
|
80
|
-
parser (>= 2.
|
|
81
|
+
parser (>= 2.7.1.1)
|
|
81
82
|
rainbow (>= 2.2.2, < 4.0)
|
|
83
|
+
regexp_parser (>= 1.7)
|
|
84
|
+
rexml
|
|
85
|
+
rubocop-ast (>= 0.1.0, < 1.0)
|
|
82
86
|
ruby-progressbar (~> 1.7)
|
|
83
|
-
unicode-display_width (>= 1.4.0, <
|
|
84
|
-
rubocop-
|
|
85
|
-
|
|
87
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
88
|
+
rubocop-ast (0.1.0)
|
|
89
|
+
parser (>= 2.7.0.1)
|
|
90
|
+
rubocop-performance (1.7.0)
|
|
91
|
+
rubocop (>= 0.82.0)
|
|
92
|
+
rubocop-rspec (1.42.0)
|
|
93
|
+
rubocop (>= 0.87.0)
|
|
86
94
|
ruby-progressbar (1.10.1)
|
|
87
|
-
simplecov (0.
|
|
95
|
+
simplecov (0.18.5)
|
|
88
96
|
docile (~> 1.1)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
url (0.3.2)
|
|
94
|
-
websocket-driver (0.7.1)
|
|
97
|
+
simplecov-html (~> 0.11)
|
|
98
|
+
simplecov-html (0.12.2)
|
|
99
|
+
unicode-display_width (1.7.0)
|
|
100
|
+
websocket-driver (0.7.3)
|
|
95
101
|
websocket-extensions (>= 0.1.0)
|
|
96
|
-
websocket-extensions (0.1.
|
|
102
|
+
websocket-extensions (0.1.5)
|
|
97
103
|
yajl-ruby (1.4.1)
|
|
98
104
|
|
|
99
105
|
PLATFORMS
|
|
@@ -106,7 +112,8 @@ DEPENDENCIES
|
|
|
106
112
|
rspec
|
|
107
113
|
rubocop
|
|
108
114
|
rubocop-performance
|
|
115
|
+
rubocop-rspec
|
|
109
116
|
salesforce_streamer!
|
|
110
117
|
|
|
111
118
|
BUNDLED WITH
|
|
112
|
-
2.
|
|
119
|
+
2.1.4
|
data/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
[](https://rubygems.org/gems/salesforce_streamer)
|
|
1
2
|
[](https://travis-ci.org/RenoFi/salesforce_streamer)
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
# SalesforceStreamer
|
|
4
|
+
# salesforce_streamer
|
|
6
5
|
|
|
7
6
|
A wrapper around the Restforce Streaming API to receive real time updates from
|
|
8
7
|
your Salesforce instance with a built-in PushTopic manager.
|
|
@@ -21,6 +20,26 @@ And then execute:
|
|
|
21
20
|
|
|
22
21
|
## Usage
|
|
23
22
|
|
|
23
|
+
### Middleware
|
|
24
|
+
|
|
25
|
+
You can initialize the streamer server with any number of middleware classes.
|
|
26
|
+
When a message is received by a PushTopic subscription, the chain of middleware
|
|
27
|
+
classes are executed before the message handler is called.
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
# config/initializers/streamer.rb
|
|
31
|
+
class MySimpleMiddleware
|
|
32
|
+
def initialize(handler)
|
|
33
|
+
@handler = handler
|
|
34
|
+
end
|
|
35
|
+
def call(message)
|
|
36
|
+
@handler.call(message)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
SalesforceStreamer.config.use_middleware MySimpleMiddleware
|
|
41
|
+
```
|
|
42
|
+
|
|
24
43
|
### Configure Push Topics
|
|
25
44
|
|
|
26
45
|
Create a YAML file to configure your server subscriptions. The configuration
|
|
@@ -63,16 +82,25 @@ push topic in Salesforce before starting the streaming server.
|
|
|
63
82
|
|
|
64
83
|
### Define Message Handlers
|
|
65
84
|
|
|
66
|
-
Define your handlers somewhere in your project. They must respond to
|
|
67
|
-
`.call(str)`.
|
|
85
|
+
Define your handlers somewhere in your project. They must respond to either
|
|
86
|
+
`.perform_async(str)` or `.call(str)`.
|
|
68
87
|
|
|
69
88
|
```ruby
|
|
70
89
|
# lib/account_change_handler.rb
|
|
90
|
+
# Handle account changes inline
|
|
71
91
|
class AccountChangeHandler
|
|
72
92
|
def self.call(message)
|
|
73
93
|
puts message
|
|
74
94
|
end
|
|
75
95
|
end
|
|
96
|
+
|
|
97
|
+
# Handle account changes asynchronously
|
|
98
|
+
class AccountChangeHandler
|
|
99
|
+
include Sidekiq::Worker
|
|
100
|
+
def perform(message)
|
|
101
|
+
puts message
|
|
102
|
+
end
|
|
103
|
+
end
|
|
76
104
|
```
|
|
77
105
|
|
|
78
106
|
### Prepare The Environment
|
|
@@ -144,7 +172,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/renofi
|
|
|
144
172
|
## License
|
|
145
173
|
|
|
146
174
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
147
|
-
|
|
148
|
-
## Code of Conduct
|
|
149
|
-
|
|
150
|
-
Everyone interacting in the SalesforceStreamer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/renofi/salesforce_streamer/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
|
@@ -9,7 +9,7 @@ module CoreExtensions
|
|
|
9
9
|
def self.extended(base)
|
|
10
10
|
base.class_eval do
|
|
11
11
|
def self.domains_match(tested_domain, base_domain)
|
|
12
|
-
return true if tested_domain[-15
|
|
12
|
+
return true if tested_domain[-15..].eql?('.salesforce.com')
|
|
13
13
|
|
|
14
14
|
# original implementation
|
|
15
15
|
base = effective_host base_domain
|
data/lib/salesforce_streamer.rb
CHANGED
|
@@ -14,7 +14,6 @@ require 'salesforce_streamer/topic_manager'
|
|
|
14
14
|
require 'salesforce_streamer/salesforce_client'
|
|
15
15
|
require 'salesforce_streamer/replay_persistence'
|
|
16
16
|
require 'salesforce_streamer/redis_replay'
|
|
17
|
-
require 'salesforce_streamer/message_receiver'
|
|
18
17
|
require 'salesforce_streamer/server'
|
|
19
18
|
require 'salesforce_streamer/version'
|
|
20
19
|
require 'salesforce_streamer/launcher'
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
module SalesforceStreamer
|
|
2
2
|
# Manages server configuration.
|
|
3
3
|
class Configuration
|
|
4
|
-
attr_accessor :environment, :logger, :require_path, :config_file, :manage_topics,
|
|
4
|
+
attr_accessor :environment, :logger, :require_path, :config_file, :manage_topics,
|
|
5
|
+
:server, :exception_adapter, :persistence_adapter, :redis_connection, :middleware
|
|
5
6
|
|
|
6
7
|
class << self
|
|
7
8
|
attr_writer :instance
|
|
@@ -19,12 +20,21 @@ module SalesforceStreamer
|
|
|
19
20
|
@manage_topics = false
|
|
20
21
|
@config_file = './config/streamer.yml'
|
|
21
22
|
@require_path = './config/environment'
|
|
23
|
+
@middleware = []
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
def manage_topics?
|
|
25
27
|
@manage_topics
|
|
26
28
|
end
|
|
27
29
|
|
|
30
|
+
def use_middleware(klass, *args, &block)
|
|
31
|
+
middleware << proc { |app| klass.new(app, *args, &block) }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def middleware_chain_for(app)
|
|
35
|
+
middleware.reduce(app) { |memo, middleware| middleware.call(memo) }
|
|
36
|
+
end
|
|
37
|
+
|
|
28
38
|
def push_topic_data
|
|
29
39
|
return @push_topic_data if @push_topic_data
|
|
30
40
|
|
|
@@ -34,7 +34,7 @@ module SalesforceStreamer
|
|
|
34
34
|
def initialize_push_topics
|
|
35
35
|
Log.debug 'Loading and validating PushTopics configuration'
|
|
36
36
|
@push_topics = []
|
|
37
|
-
Configuration.instance.push_topic_data.
|
|
37
|
+
Configuration.instance.push_topic_data.each_value do |topic_data|
|
|
38
38
|
Log.debug topic_data.to_s
|
|
39
39
|
@push_topics << PushTopic.new(data: topic_data)
|
|
40
40
|
end
|
|
@@ -6,13 +6,13 @@ module SalesforceStreamer
|
|
|
6
6
|
:handler, :handler_constant, :api_version
|
|
7
7
|
|
|
8
8
|
def initialize(data:)
|
|
9
|
-
@handler
|
|
10
|
-
@static_replay
|
|
11
|
-
@name
|
|
12
|
-
@api_version
|
|
13
|
-
@description
|
|
9
|
+
@handler = data['handler']
|
|
10
|
+
@static_replay = data.dig('replay')&.to_i || -1
|
|
11
|
+
@name = data.dig('salesforce', 'name')
|
|
12
|
+
@api_version = data.dig('salesforce', 'api_version') || '41.0'
|
|
13
|
+
@description = data.dig('salesforce', 'description') || @name
|
|
14
14
|
@notify_for_fields = data.dig('salesforce', 'notify_for_fields') || 'Referenced'
|
|
15
|
-
@query
|
|
15
|
+
@query = strip_spaces(data.dig('salesforce', 'query'))
|
|
16
16
|
validate!
|
|
17
17
|
end
|
|
18
18
|
|
|
@@ -20,6 +20,15 @@ module SalesforceStreamer
|
|
|
20
20
|
ReplayPersistence.retrieve(name) || @static_replay
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
def handle(message)
|
|
24
|
+
message['topic'] = @name
|
|
25
|
+
handle_chain.call(message)
|
|
26
|
+
ReplayPersistence.record @name, message.dig('event', 'replayId')
|
|
27
|
+
rescue StandardError => e
|
|
28
|
+
Log.error e
|
|
29
|
+
Configuration.instance.exception_adapter.call e
|
|
30
|
+
end
|
|
31
|
+
|
|
23
32
|
def to_s
|
|
24
33
|
"PushTopic id=#{id} name=#{name} handler=#{handler} " \
|
|
25
34
|
"replay=#{replay} notify_for_fields=#{notify_for_fields} " \
|
|
@@ -38,6 +47,18 @@ module SalesforceStreamer
|
|
|
38
47
|
raise(PushTopicHandlerMissingError, message)
|
|
39
48
|
end
|
|
40
49
|
|
|
50
|
+
def handle_chain
|
|
51
|
+
Configuration.instance.middleware_chain_for(handler_proc)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def handler_proc
|
|
55
|
+
if handler_constant.respond_to? :perform_async
|
|
56
|
+
proc { |message| handler_constant.perform_async message }
|
|
57
|
+
else
|
|
58
|
+
handler_constant
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
41
62
|
def strip_spaces(str)
|
|
42
63
|
fail(NilQueryError, @name) unless str
|
|
43
64
|
|
|
@@ -34,9 +34,11 @@ module SalesforceStreamer
|
|
|
34
34
|
def start_em
|
|
35
35
|
EM.run do
|
|
36
36
|
@push_topics.map do |topic|
|
|
37
|
-
client.subscribe topic.name, replay: topic.replay.to_i do |
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
client.subscribe topic.name, replay: topic.replay.to_i do |message|
|
|
38
|
+
replay_id = message.dig('event', 'replayId')
|
|
39
|
+
Log.info "Message #{replay_id} received from topic #{topic.name}"
|
|
40
|
+
topic.handle message
|
|
41
|
+
topic.id = replay_id
|
|
40
42
|
end
|
|
41
43
|
end
|
|
42
44
|
end
|
data/salesforce_streamer.gemspec
CHANGED
|
@@ -3,26 +3,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
3
3
|
require 'salesforce_streamer/version'
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name
|
|
7
|
-
spec.version
|
|
8
|
-
spec.authors
|
|
9
|
-
spec.email
|
|
6
|
+
spec.name = 'salesforce_streamer'
|
|
7
|
+
spec.version = SalesforceStreamer::VERSION
|
|
8
|
+
spec.authors = ['Scott Serok', 'RenoFi Engineering Team']
|
|
9
|
+
spec.email = ['scott@renofi.com', 'engineering@renofi.com']
|
|
10
10
|
|
|
11
|
-
spec.summary
|
|
12
|
-
spec.homepage
|
|
13
|
-
spec.license
|
|
11
|
+
spec.summary = 'A wrapper around the Restforce Streaming API with a built-in PushTopic manager.'
|
|
12
|
+
spec.homepage = 'https://github.com/renofi/salesforce_streamer'
|
|
13
|
+
spec.license = 'MIT'
|
|
14
14
|
|
|
15
|
-
spec.metadata['homepage_uri']
|
|
15
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
16
16
|
spec.metadata['source_code_uri'] = spec.homepage
|
|
17
17
|
|
|
18
18
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
19
19
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin/|spec/|\.rub)}) }
|
|
20
20
|
end
|
|
21
|
-
spec.bindir
|
|
22
|
-
spec.executables
|
|
21
|
+
spec.bindir = 'exe'
|
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
23
|
spec.require_paths = ['lib']
|
|
24
24
|
|
|
25
|
-
spec.required_ruby_version = '>= 2.
|
|
25
|
+
spec.required_ruby_version = '>= 2.6'
|
|
26
26
|
|
|
27
27
|
spec.add_dependency 'faye', '0.8.9'
|
|
28
28
|
spec.add_dependency 'restforce', '~> 4.2'
|
|
@@ -33,4 +33,5 @@ Gem::Specification.new do |spec|
|
|
|
33
33
|
spec.add_development_dependency 'rspec'
|
|
34
34
|
spec.add_development_dependency 'rubocop'
|
|
35
35
|
spec.add_development_dependency 'rubocop-performance'
|
|
36
|
+
spec.add_development_dependency 'rubocop-rspec'
|
|
36
37
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: salesforce_streamer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Scott Serok
|
|
8
|
+
- RenoFi Engineering Team
|
|
8
9
|
autorequire:
|
|
9
10
|
bindir: exe
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
+
date: 2020-08-03 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
15
|
name: faye
|
|
@@ -122,18 +123,38 @@ dependencies:
|
|
|
122
123
|
- - ">="
|
|
123
124
|
- !ruby/object:Gem::Version
|
|
124
125
|
version: '0'
|
|
126
|
+
- !ruby/object:Gem::Dependency
|
|
127
|
+
name: rubocop-rspec
|
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
|
129
|
+
requirements:
|
|
130
|
+
- - ">="
|
|
131
|
+
- !ruby/object:Gem::Version
|
|
132
|
+
version: '0'
|
|
133
|
+
type: :development
|
|
134
|
+
prerelease: false
|
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
136
|
+
requirements:
|
|
137
|
+
- - ">="
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
version: '0'
|
|
125
140
|
description:
|
|
126
141
|
email:
|
|
127
142
|
- scott@renofi.com
|
|
143
|
+
- engineering@renofi.com
|
|
128
144
|
executables:
|
|
129
145
|
- streamer
|
|
130
146
|
extensions: []
|
|
131
147
|
extra_rdoc_files: []
|
|
132
148
|
files:
|
|
149
|
+
- ".dependabot/config.yml"
|
|
150
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
|
151
|
+
- ".github/ISSUE_TEMPLATE/config.yml"
|
|
152
|
+
- ".github/ISSUE_TEMPLATE/story.md"
|
|
153
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
|
154
|
+
- ".github/workflows/auto-approve.yml"
|
|
133
155
|
- ".gitignore"
|
|
134
156
|
- ".rspec"
|
|
135
157
|
- ".travis.yml"
|
|
136
|
-
- CODE_OF_CONDUCT.md
|
|
137
158
|
- Gemfile
|
|
138
159
|
- Gemfile.lock
|
|
139
160
|
- LICENSE.txt
|
|
@@ -147,7 +168,6 @@ files:
|
|
|
147
168
|
- lib/salesforce_streamer/errors.rb
|
|
148
169
|
- lib/salesforce_streamer/launcher.rb
|
|
149
170
|
- lib/salesforce_streamer/log.rb
|
|
150
|
-
- lib/salesforce_streamer/message_receiver.rb
|
|
151
171
|
- lib/salesforce_streamer/push_topic.rb
|
|
152
172
|
- lib/salesforce_streamer/redis_replay.rb
|
|
153
173
|
- lib/salesforce_streamer/replay_id_error_extension.rb
|
|
@@ -171,14 +191,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
171
191
|
requirements:
|
|
172
192
|
- - ">="
|
|
173
193
|
- !ruby/object:Gem::Version
|
|
174
|
-
version: '2.
|
|
194
|
+
version: '2.6'
|
|
175
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
196
|
requirements:
|
|
177
197
|
- - ">="
|
|
178
198
|
- !ruby/object:Gem::Version
|
|
179
199
|
version: '0'
|
|
180
200
|
requirements: []
|
|
181
|
-
rubygems_version: 3.
|
|
201
|
+
rubygems_version: 3.1.2
|
|
182
202
|
signing_key:
|
|
183
203
|
specification_version: 4
|
|
184
204
|
summary: A wrapper around the Restforce Streaming API with a built-in PushTopic manager.
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
-
orientation.
|
|
11
|
-
|
|
12
|
-
## Our Standards
|
|
13
|
-
|
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
|
15
|
-
include:
|
|
16
|
-
|
|
17
|
-
* Using welcoming and inclusive language
|
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
|
19
|
-
* Gracefully accepting constructive criticism
|
|
20
|
-
* Focusing on what is best for the community
|
|
21
|
-
* Showing empathy towards other community members
|
|
22
|
-
|
|
23
|
-
Examples of unacceptable behavior by participants include:
|
|
24
|
-
|
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
-
advances
|
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
-
* Public or private harassment
|
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
|
30
|
-
address, without explicit permission
|
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
-
professional setting
|
|
33
|
-
|
|
34
|
-
## Our Responsibilities
|
|
35
|
-
|
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
-
response to any instances of unacceptable behavior.
|
|
39
|
-
|
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
-
threatening, offensive, or harmful.
|
|
45
|
-
|
|
46
|
-
## Scope
|
|
47
|
-
|
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
-
when an individual is representing the project or its community. Examples of
|
|
50
|
-
representing a project or community include using an official project e-mail
|
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
|
53
|
-
further defined and clarified by project maintainers.
|
|
54
|
-
|
|
55
|
-
## Enforcement
|
|
56
|
-
|
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
-
reported by contacting the project team at scott@renofi.com. All
|
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
|
63
|
-
|
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
-
members of the project's leadership.
|
|
67
|
-
|
|
68
|
-
## Attribution
|
|
69
|
-
|
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
-
|
|
73
|
-
[homepage]: http://contributor-covenant.org
|
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module SalesforceStreamer
|
|
2
|
-
class MessageReceiver
|
|
3
|
-
class << self
|
|
4
|
-
# @param topic [String] The unique Salesforce Topic name
|
|
5
|
-
# @param handler [Object] An object that responds to .call(message)
|
|
6
|
-
# @param message [Hash] The event payload
|
|
7
|
-
def call(topic, handler, message)
|
|
8
|
-
if handler.respond_to? :perform_async
|
|
9
|
-
handler.perform_async message
|
|
10
|
-
else
|
|
11
|
-
handler.call message
|
|
12
|
-
end
|
|
13
|
-
ReplayPersistence.record topic, message.dig('event', 'replayId')
|
|
14
|
-
rescue StandardError => e
|
|
15
|
-
Configuration.instance.exception_adapter.call e
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|