restforce-db 2.1.6 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/restforce/db/command.rb +4 -6
- data/lib/restforce/db/configuration.rb +7 -5
- data/lib/restforce/db/version.rb +1 -1
- data/lib/restforce/db/worker.rb +2 -0
- data/lib/restforce/db.rb +1 -1
- data/test/lib/restforce/db/configuration_test.rb +16 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71c79dd792a31d0dc8a920302fd0f66d897750ef
|
4
|
+
data.tar.gz: 268dab371d9549a15100014c873ba6ee7d603a23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f92441f1d521bac62ca537d5687f5082717f1ed743b89c10ab271ca3e4aa28b5088597f841c4659bc63568040ebcc16b8382d47e12eee27f46fc2f6e25b6bf35
|
7
|
+
data.tar.gz: 7be9676f2c5052325da2fa3c0722edf5bc0c2a5afa549f9d1dc5254396a0f9b368646ac1112f62204a36fba935c2ea71a889377a863cf4f5cec4850e110b66d0
|
data/README.md
CHANGED
@@ -226,11 +226,11 @@ For additional information and a full set of options, you can run:
|
|
226
226
|
|
227
227
|
#### Configuring the daemon's runtime environment
|
228
228
|
|
229
|
-
Restforce::DB allows you to configure
|
229
|
+
Restforce::DB allows you to configure a block of code which will execute before the daemon process's polling loop initiates. In an initializer (or any other piece of code which will run as your application spins up), you can use `config.before` to set up this hook:
|
230
230
|
|
231
231
|
```ruby
|
232
232
|
Restforce::DB.configure do |config|
|
233
|
-
config.
|
233
|
+
config.before { |_worker| ActiveRecord::Base.logger = nil }
|
234
234
|
end
|
235
235
|
```
|
236
236
|
|
data/lib/restforce/db/command.rb
CHANGED
@@ -56,20 +56,18 @@ module Restforce
|
|
56
56
|
def run(options = {})
|
57
57
|
Dir.chdir(Rails.root)
|
58
58
|
|
59
|
-
Restforce::DB.logger = logger
|
60
|
-
|
61
59
|
# This hook comes from the FileDaemon module, and keeps file descriptors
|
62
60
|
# opened after the process forks.
|
63
61
|
Restforce::DB::Worker.after_fork
|
64
62
|
|
65
|
-
# This hook can be configured in an initializer, and allows changes to
|
66
|
-
# the runtime environment after the process forks.
|
67
|
-
Restforce::DB.after_fork
|
68
|
-
|
69
63
|
worker = Restforce::DB::Worker.new(options)
|
70
64
|
worker.logger = logger
|
71
65
|
worker.tracker = tracker
|
72
66
|
|
67
|
+
# This hook can be configured in an initializer, and allows changes to
|
68
|
+
# the worker before the daemon loop begins processing.
|
69
|
+
Restforce::DB.before(worker)
|
70
|
+
|
73
71
|
worker.start
|
74
72
|
rescue => e
|
75
73
|
logger.fatal e
|
@@ -21,17 +21,19 @@ module Restforce
|
|
21
21
|
logger
|
22
22
|
))
|
23
23
|
|
24
|
-
# Public: Allow
|
25
|
-
# previously-configured block if called without
|
24
|
+
# Public: Allow a `before` callback to be configured or run. Runs the
|
25
|
+
# previously-configured block with any passed objects if called without a
|
26
|
+
# block.
|
26
27
|
#
|
28
|
+
# args - An arbitrary collection of arguments to pass to the hook.
|
27
29
|
# block - A block of code to execute after process forking.
|
28
30
|
#
|
29
31
|
# Returns nothing.
|
30
|
-
def
|
32
|
+
def before(*args, &block)
|
31
33
|
if block_given?
|
32
|
-
@
|
34
|
+
@before_hook = block
|
33
35
|
else
|
34
|
-
@
|
36
|
+
@before_hook.call(*args) if @before_hook
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
data/lib/restforce/db/version.rb
CHANGED
data/lib/restforce/db/worker.rb
CHANGED
data/lib/restforce/db.rb
CHANGED
@@ -8,29 +8,38 @@ describe Restforce::DB::Configuration do
|
|
8
8
|
let(:secrets_file) { File.expand_path("../../../../config/secrets.yml", __FILE__) }
|
9
9
|
let(:configuration) { Restforce::DB::Configuration.new }
|
10
10
|
|
11
|
-
describe "#
|
11
|
+
describe "#before" do
|
12
12
|
|
13
13
|
it "does nothing if invoked without a block" do
|
14
14
|
# NOTE: We're asserting that this invocation doesn't raise an error.
|
15
|
-
configuration.
|
15
|
+
configuration.before
|
16
16
|
end
|
17
17
|
|
18
|
-
it "does not invoke the
|
18
|
+
it "does not invoke the hook on configuration" do
|
19
19
|
a = 1
|
20
20
|
|
21
|
-
configuration.
|
21
|
+
configuration.before { a += 1 }
|
22
22
|
|
23
23
|
expect(a).to_equal 1
|
24
24
|
end
|
25
25
|
|
26
|
-
it "invokes the configured
|
26
|
+
it "invokes the configured hook when called without a block" do
|
27
27
|
a = 1
|
28
28
|
|
29
|
-
configuration.
|
30
|
-
configuration.
|
29
|
+
configuration.before { a += 1 }
|
30
|
+
configuration.before
|
31
31
|
|
32
32
|
expect(a).to_equal 2
|
33
33
|
end
|
34
|
+
|
35
|
+
it "invokes the configured hook with passed arguments" do
|
36
|
+
a = 1
|
37
|
+
|
38
|
+
configuration.before { |b| a += b }
|
39
|
+
configuration.before(2)
|
40
|
+
|
41
|
+
expect(a).to_equal 3
|
42
|
+
end
|
34
43
|
end
|
35
44
|
|
36
45
|
describe "#logger" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restforce-db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Horner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|