oso-cloud 1.3.0.dev.6 → 1.3.0.dev.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14b5b319f475adefc2e05c6bf2e9cf6f22b20164d38fb9c1cb59b1b7c6c291ee
4
- data.tar.gz: d9d50d1adcc35c04309b65cde6d2d802eec75ccdd62d6b2d5e05907e7bb9806f
3
+ metadata.gz: 844583229037d7124d91b588abfbef062026c934d5cd1dcd0e4892a6d539b969
4
+ data.tar.gz: 889f910639d097b5c5e29fa64e36959a7c7aebbe7ffe48dfa080f8bbef119015
5
5
  SHA512:
6
- metadata.gz: e8f770aaefda73dba90e6410be04dec0dc5ec1089535d7977f1aa5bd1d6310023954c6e2aae3e1d6c9e458ef2ceb5df58cf7dd16bc3c3183036da4965fcdaf02
7
- data.tar.gz: 669d14ebf88e20a6f2a1bebdc609a7bda2e3eb6c20fc3d5eb7f4efa2b686ea611bc5a7ad28dcd4cd450a36226f1df5594daa09927a755d91ab97abe819363181
6
+ metadata.gz: 77883cfc4f1584d65a31f1d620d239bcb98b70de099320c91590de55b4a39ee8b4aa7d5c80bbe7b94b8f6f16a02aeab6d54efb5aeecb1a289e7f93ac9048e1a8
7
+ data.tar.gz: ecd8b9f6377a4465b9cc39622d35da59a548229ab6df9edc212859e0f282041a812644c02f4cc9e25065e047e805d1fd594b69f5adeb9b40e4e0a4ddab5711a2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oso-cloud (1.3.0.dev.5)
4
+ oso-cloud (1.3.0.dev.6)
5
5
  faraday (~> 2.5.2)
6
6
  faraday-net_http_persistent (~> 2.0)
7
7
  faraday-retry (~> 2.0.0)
data/lib/oso/api.rb CHANGED
@@ -203,6 +203,17 @@ module OsoCloud
203
203
  end
204
204
  end
205
205
 
206
+ class OsoAdapter < Faraday::Adapter::Typhoeus
207
+ @@max_concurrency = 20
208
+
209
+ def self.setup_parallel_manager(options = {})
210
+ options[:max_concurrency] = @@max_concurrency
211
+ ::Typhoeus::Hydra.new(options)
212
+ end
213
+ end
214
+
215
+ Faraday::Adapter.register_middleware(oso_http: OsoAdapter)
216
+
206
217
  # @!visibility private
207
218
  class Api
208
219
  def get_connection(options: nil)
@@ -214,6 +225,7 @@ module OsoCloud
214
225
  # parser is only applied if there are no errors
215
226
  faraday.response :json, parser_options: { symbolize_names: true }
216
227
  faraday.response :raise_error
228
+ # faraday.response :logger
217
229
  faraday.request :retry, {
218
230
  max: (options && options[:max_retries]) || 10,
219
231
  interval: 0.01,
@@ -247,17 +259,20 @@ module OsoCloud
247
259
  end
248
260
  end
249
261
  elsif options && options[:parallel_adapter]
250
- faraday.adapter :typhoeus, forbid_reuse: false, maxredirs: 1, connecttimeout: 30
262
+ if options[:max_concurrency]
263
+ OsoAdapter.class_variable_set(:@@max_concurrency, options[:max_concurrency])
264
+ end
265
+ faraday.adapter :oso_http, forbid_reuse: false, maxredirs: 1, connecttimeout: 30
251
266
  else
252
267
  faraday.adapter :net_http_persistent, pool_size: 10, idle_timeout: 30
253
268
  end
254
269
  end
255
270
  end
256
271
 
257
- def initialize(url: 'https://api.osohq.com', api_key: nil, options: nil)
272
+ def initialize(url: 'https://api.osohq.com', api_key: nil, options: {})
258
273
  @url = url
259
274
  @connection = get_connection(options: options)
260
- @parallel_connection = get_connection(options: { parallel_adapter: true })
275
+ @parallel_connection = get_connection(options: { parallel_adapter: true, max_concurrency: options[:max_concurrency] })
261
276
  @api_key = api_key
262
277
  @user_agent = "Oso Cloud (ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}; rv:#{VERSION})"
263
278
  @last_offset = nil
data/lib/oso/oso.rb CHANGED
@@ -28,8 +28,8 @@ module OsoCloud
28
28
  # Any other elements in the array, which together represent the fact's arguments,
29
29
  # can be "OsoCloud::Value" objects or strings.
30
30
  class Oso
31
- def initialize(url: 'https://cloud.osohq.com', api_key: nil)
32
- @api = OsoCloud::Core::Api.new(url: url, api_key: api_key)
31
+ def initialize(url: 'https://cloud.osohq.com', api_key: nil, options: nil)
32
+ @api = OsoCloud::Core::Api.new(url: url, api_key: api_key, options: options || {})
33
33
  end
34
34
 
35
35
  # Update the active policy
data/lib/oso/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OsoCloud
2
- VERSION = '1.3.0.dev.6'.freeze
2
+ VERSION = '1.3.0.dev.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oso-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.dev.6
4
+ version: 1.3.0.dev.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oso Security, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-02 00:00:00.000000000 Z
11
+ date: 2023-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday