restforce-db 3.2.2 → 3.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1278678ebc70c7c955fb0dd857dbabe6f2bb2df1
4
- data.tar.gz: e2368e5b966d3e7934e3395c350917d3563549d1
3
+ metadata.gz: 426c96af98332d2afd82da60f56121eaae4197e2
4
+ data.tar.gz: 7d6fdb0c0b304e9ce2cd4149e502a85cf6b98263
5
5
  SHA512:
6
- metadata.gz: 0fab8292b39f202beb9b5c43080d0ed67d3077a9d5048919683d6ce9fbc05c537c4900b7798623aaeb8c679e1fdb828af00fba24c87a0568f4bc769cdc0330e5
7
- data.tar.gz: aa2c720cdd35f01cb23bedbc58000f8baed4b9d582ac49ab0021024b2f0e1a23e0d0a6b5067f4a12e42dcecd44d91ec5175ed36455c57dc69ce6663e5947c947
6
+ metadata.gz: ed5d4a11b2b27fe9003e81c9ed0b68cd86fd43cc706d77443d43ee182f8726f35030efe030a65d17ba2a72439850da7a03d03e8941276b523cf3af10a451fe17
7
+ data.tar.gz: 9226923f587bbefa6e041a0a918e7e36b9e22ddcd5d78f991449a630854cdf1ec9684b3e4c7d37ad6f17fed4913fbce385f9e2f11491e897cc641c1427f12676
data/README.md CHANGED
@@ -319,6 +319,10 @@ If you're testing your integration, and using something like VCR to record your
319
319
 
320
320
  Restforce::DB attempts to mitigate this effect by tracking change timestamps for internal updates.
321
321
 
322
+ ## Instrumentation
323
+
324
+ Restforce::DB uses a [Faraday](https://github.com/lostisland/faraday) middleware to add API interaction [instrumentation](https://github.com/lostisland/faraday_middleware/blob/master/lib/faraday_middleware/instrumentation.rb), as described in [Restforce's documentation](https://github.com/ejholmes/restforce#loggingdebugginginstrumenting) through [Active Support notifications](http://guides.rubyonrails.org/active_support_instrumentation.html).
325
+
322
326
  ## Development
323
327
 
324
328
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -0,0 +1,31 @@
1
+ module Restforce
2
+
3
+ module DB
4
+
5
+ module Middleware
6
+
7
+ # Public: A Faraday middleware to store the request body in the environment.
8
+ #
9
+ # This works around an issue with Faraday where the request body is squashed by
10
+ # the response body, once a request has been made.
11
+ #
12
+ # See also:
13
+ # - https://github.com/lostisland/faraday/issues/163
14
+ # - https://github.com/lostisland/faraday/issues/297
15
+ class StoreRequestBody < Faraday::Middleware
16
+
17
+ # Public: Executes this middleware.
18
+ #
19
+ # request_env - The request's Env from Faraday.
20
+ def call(request_env)
21
+ request_env[:request_body] = request_env[:body]
22
+ @app.call(request_env)
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -3,7 +3,7 @@ module Restforce
3
3
  # :nodoc:
4
4
  module DB
5
5
 
6
- VERSION = "3.2.2"
6
+ VERSION = "3.3.0"
7
7
 
8
8
  end
9
9
 
data/lib/restforce/db.rb CHANGED
@@ -5,6 +5,7 @@ require "restforce/extensions"
5
5
 
6
6
  require "restforce/db/version"
7
7
  require "restforce/db/client"
8
+ require "restforce/db/middleware/store_request_body"
8
9
  require "restforce/db/configuration"
9
10
  require "restforce/db/registry"
10
11
  require "restforce/db/strategy"
@@ -96,20 +97,36 @@ module Restforce
96
97
  timeout: configuration.timeout,
97
98
  adapter: configuration.adapter,
98
99
  )
99
-
100
- # NOTE: By default, the Retry middleware will catch timeout exceptions,
101
- # and retry up to two times. For more information, see:
102
- # https://github.com/lostisland/faraday/blob/master/lib/faraday/request/retry.rb
103
- client.middleware.insert(
104
- -2,
105
- Faraday::Request::Retry,
106
- methods: [:get, :head, :options, :put, :patch, :delete],
107
- )
108
-
100
+ setup_middleware(client)
109
101
  client
110
102
  end
111
103
  end
112
104
 
105
+ # Internal: Sets up the Restforce client's middleware handlers.
106
+ #
107
+ # Returns nothing.
108
+ def self.setup_middleware(client)
109
+ # NOTE: By default, the Retry middleware will catch timeout exceptions,
110
+ # and retry up to two times. For more information, see:
111
+ # https://github.com/lostisland/faraday/blob/master/lib/faraday/request/retry.rb
112
+ client.middleware.insert(
113
+ -2,
114
+ Faraday::Request::Retry,
115
+ methods: [:get, :head, :options, :put, :patch, :delete],
116
+ )
117
+
118
+ client.middleware.insert_after(
119
+ Restforce::Middleware::InstanceURL,
120
+ FaradayMiddleware::Instrumentation,
121
+ name: "request.restforce_db",
122
+ )
123
+
124
+ client.middleware.insert_before(
125
+ FaradayMiddleware::Instrumentation,
126
+ Restforce::DB::Middleware::StoreRequestBody,
127
+ )
128
+ end
129
+
113
130
  # Public: Get the ID of the Salesforce user which is being used to access
114
131
  # the Salesforce API.
115
132
  #
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: 3.2.2
4
+ version: 3.3.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-07-16 00:00:00.000000000 Z
11
+ date: 2015-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -230,6 +230,7 @@ files:
230
230
  - lib/restforce/db/instances/base.rb
231
231
  - lib/restforce/db/instances/salesforce.rb
232
232
  - lib/restforce/db/mapping.rb
233
+ - lib/restforce/db/middleware/store_request_body.rb
233
234
  - lib/restforce/db/model.rb
234
235
  - lib/restforce/db/railtie.rb
235
236
  - lib/restforce/db/record_cache.rb