salesforce_streamer 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/Gemfile.lock +1 -1
- data/README.md +23 -3
- data/lib/salesforce_streamer/cli.rb +1 -1
- data/lib/salesforce_streamer/configuration.rb +1 -1
- data/lib/salesforce_streamer/push_topic.rb +1 -1
- data/lib/salesforce_streamer/salesforce_client.rb +2 -4
- data/lib/salesforce_streamer/server.rb +2 -5
- 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: b7aa51a1aab875d18d027a1686a598d795d30126cea6fc81f08e705911bdc92c
|
4
|
+
data.tar.gz: ce9f47fdc1f3c277347c684fc533e92e56e93779c3115a0894f8834c1196b795
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d7183472e280c49188c8f0a386ddf24e47ee99cd827b0e1b9bb3c22184136ef81694364020a4c6676f728317af530e5959908fe79d871ba065d43f29b0c5f97
|
7
|
+
data.tar.gz: 329f63f5ced7e03256761765e70a3d13107779fa895e249e69e07e98d148ed1142b0f23c9e8cc86d38faae92087af59080524cef60a70ba51619ab4ec9cdd36b
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,38 @@
|
|
3
3
|
Sorted so that the most recent change logs are near the top. Only significant
|
4
4
|
changes are logged in the change log.
|
5
5
|
|
6
|
+
## 2020-08-17 Scott Serok [scott@renofi.com](mailto:scott@renofi.com)
|
7
|
+
|
8
|
+
v2.1 changes the expected interface of `Configuration#replay_adapter`.
|
9
|
+
|
10
|
+
Normally this breaking change would require a major version bump, but since the
|
11
|
+
functionality today is quiet broken we can call this a major bug fix.
|
12
|
+
|
13
|
+
The `config.replay_adapter` should be an object that has an interface like Hash.
|
14
|
+
It must respond to `[]` and `[]=`. By default the adapter is an empty hash. If
|
15
|
+
you want your push topic replayId to persist between restarts, then you should
|
16
|
+
implement a class with an appropriate interface.
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
class MyReplayAdapter
|
20
|
+
def [](channel)
|
21
|
+
MyPersistence.get(channel)
|
22
|
+
end
|
23
|
+
|
24
|
+
def []=(channel, replay_id)
|
25
|
+
MyPersistence.set(channel, replay_id)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
This change was sparked by a misunderstanding of the
|
31
|
+
`Restforce::Concerns::Streaming::ReplayExtension` replay handlers.
|
32
|
+
SalesforceStreamer can eliminate some complexity and fix a bug by delegating the
|
33
|
+
responsibility of maintaining the current replayId to that ReplayExtension. The
|
34
|
+
object will be used on each request/response cycle to record and read the latest
|
35
|
+
replayId as long as the object assigned to `config.replay_adapter` responds to
|
36
|
+
`[]` and `[]=`.
|
37
|
+
|
6
38
|
## 2020-08-04 Scott Serok [scott@renofi.com](mailto:scott@renofi.com)
|
7
39
|
|
8
40
|
v2.0 is released as a major simplification of this library. There are 2
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -89,9 +89,7 @@ Configure the `SalesforceStreamer` module.
|
|
89
89
|
SalesforceStreamer.configure do |config|
|
90
90
|
config.logger = Logger.new(STDERR, level: 'INFO')
|
91
91
|
config.exception_adapter = proc { |e| puts e }
|
92
|
-
config.replay_adapter =
|
93
|
-
(ReplayStore.get(topic.name) || topic.replay).to_i
|
94
|
-
}
|
92
|
+
config.replay_adapter = MyReplayAdapter
|
95
93
|
config.use_middleware AfterMessageReceived
|
96
94
|
config.manage_topics = true
|
97
95
|
end
|
@@ -153,6 +151,28 @@ end
|
|
153
151
|
|
154
152
|
SalesforceStreamer.config.use_middleware MySimpleMiddleware
|
155
153
|
```
|
154
|
+
|
155
|
+
### ReplayAdapter
|
156
|
+
|
157
|
+
The `config.replay_adapter` should be an object that has an interface like Hash.
|
158
|
+
It must respond to `[]` and `[]=`. By default the adapter is an empty hash. If
|
159
|
+
you want your push topic replayId to persist between restarts, then you should
|
160
|
+
implement a class with an appropriate interface.
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
class MyReplayAdapter
|
164
|
+
def [](channel)
|
165
|
+
Persistence.get(channel)
|
166
|
+
end
|
167
|
+
|
168
|
+
def []=(channel, replay_id)
|
169
|
+
Persistence.set(channel, replay_id)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
```
|
173
|
+
|
174
|
+
This adapter will be used directly by `Restforce::ReplayExtension`.
|
175
|
+
|
156
176
|
## Development
|
157
177
|
|
158
178
|
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.
|
@@ -32,7 +32,7 @@ module SalesforceStreamer
|
|
32
32
|
end
|
33
33
|
|
34
34
|
o.on '-v', '--verbose LEVEL', 'Set the log level (default no logging)' do |arg|
|
35
|
-
@config.logger = Logger.new(
|
35
|
+
@config.logger = Logger.new($stderr, level: arg)
|
36
36
|
end
|
37
37
|
|
38
38
|
o.on '-V', '--version', 'Print the version information' do
|
@@ -21,7 +21,7 @@ module SalesforceStreamer
|
|
21
21
|
@environment = ENV['RACK_ENV'] || :development
|
22
22
|
@logger = Logger.new(IO::NULL)
|
23
23
|
@exception_adapter = proc { |exc| fail(exc) }
|
24
|
-
@replay_adapter =
|
24
|
+
@replay_adapter = Hash.new { |hash, key| hash[key] = -1 }
|
25
25
|
@manage_topics = false
|
26
26
|
@config_file = './config/streamer.yml'
|
27
27
|
@require_path = './config/environment'
|
@@ -34,7 +34,7 @@ module SalesforceStreamer
|
|
34
34
|
@handler = Object.const_get(@handler)
|
35
35
|
true
|
36
36
|
rescue NameError, TypeError => e
|
37
|
-
message =
|
37
|
+
message = "handler=#{@handler} exception=#{e}"
|
38
38
|
raise(PushTopicHandlerMissingError, message)
|
39
39
|
end
|
40
40
|
|
@@ -8,10 +8,8 @@ module SalesforceStreamer
|
|
8
8
|
@client.authenticate!
|
9
9
|
end
|
10
10
|
|
11
|
-
def subscribe(*args)
|
12
|
-
@client.subscribe(args)
|
13
|
-
yield
|
14
|
-
end
|
11
|
+
def subscribe(*args, &block)
|
12
|
+
@client.subscribe(args, &block)
|
15
13
|
end
|
16
14
|
|
17
15
|
# Returns nil or an instance of Restforce::SObject
|
@@ -34,12 +34,9 @@ module SalesforceStreamer
|
|
34
34
|
def start_em
|
35
35
|
EM.run do
|
36
36
|
@push_topics.map do |topic|
|
37
|
-
|
38
|
-
|
39
|
-
replay_id = message.dig('event', 'replayId')
|
40
|
-
Log.info "Message #{replay_id} received from topic #{topic.name}"
|
37
|
+
client.subscribe topic.name, replay: Configuration.instance.replay_adapter do |message|
|
38
|
+
Log.info "Message #{message.dig('event', 'replayId')} received from topic #{topic.name}"
|
41
39
|
topic.handle message
|
42
|
-
topic.id = replay_id
|
43
40
|
end
|
44
41
|
end
|
45
42
|
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.1.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-08-
|
12
|
+
date: 2020-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dry-initializer
|