rorvswild 1.0.0 → 1.0.1

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: 5de21021b3f979d7215d9bf5239bd9aff7b900c4
4
- data.tar.gz: 7c92d609483bc2b941b633246e3ad4281e6102b1
3
+ metadata.gz: 3f8e0e177bc8b3c9645a79f0b4d39fcf27ed804f
4
+ data.tar.gz: 31e58a5359e4b691d80d23c23dddfaedb9a3fc76
5
5
  SHA512:
6
- metadata.gz: 01e51d49b9db2a00a8360a964b7e213529f7bc21aab5d75ee7cd322769e77da16a173b32501e0b50544faa70a3476c0d987d78f903e28fcca4c58ea798ca5fb8
7
- data.tar.gz: d62ae92b5032dd2db020097f4339bf475fa888b5146be3c9512b1ce2112d37a17c621639a53fb9826e03f5738e7439fbde8e58b59be6796d9d080d3625c55cf7
6
+ metadata.gz: 39a57beba2498edf1ea8e1790a45991f434cfe89e925717a55c0353500d1d62a4068149510ebb24e197d82c9fa10ae9252bedea1316a0ad17694244688501382
7
+ data.tar.gz: bd19b326fb647010c5fba1db667804c50742b12c97ff97d58509a99b7922aed9e80ce170a78165cee50e0a9cc96a8eab45b0d046a0a03e6c964bf904d8739a50
data/README.md CHANGED
@@ -81,7 +81,7 @@ production:
81
81
 
82
82
  ```ruby
83
83
  # config/initializers/rorvswild.rb
84
- RorVsWild::Client.new(
84
+ RorVsWild.start(
85
85
  api_key: "API_KEY",
86
86
  ignored_exceptions: ["ActionController::RoutingError", "ZeroDivisionError"])
87
87
  ```
@@ -17,6 +17,9 @@ module RorVsWild
17
17
  @api_key = config[:api_key]
18
18
  @timeout ||= config[:timeout] || DEFAULT_TIMEOUT
19
19
  @threads = Set.new
20
+ @connections = []
21
+ @connection_count = 0
22
+ @mutex = Mutex.new
20
23
  end
21
24
 
22
25
  def post(path, data)
@@ -25,11 +28,36 @@ module RorVsWild
25
28
  post.content_type = "application/json".freeze
26
29
  post.basic_auth(nil, api_key)
27
30
  post.body = data.to_json
28
- http.request(post)
31
+ transmit(post)
29
32
  end
30
33
 
31
- def http
32
- @http ||= new_http
34
+ def take_connection
35
+ @mutex.synchronize { @connections.shift }
36
+ end
37
+
38
+ def release_connection(http)
39
+ @mutex.synchronize { @connections.push(http) } if http
40
+ end
41
+
42
+ def max_connections
43
+ @max_connections ||= [Process.getrlimit(Process::RLIMIT_NOFILE).first / 10, 10].max
44
+ end
45
+
46
+ def take_or_create_connection
47
+ if http = take_connection
48
+ http
49
+ elsif @connection_count < max_connections
50
+ @connection_count += 1
51
+ new_http
52
+ end
53
+ end
54
+
55
+ def transmit(request)
56
+ if http = take_or_create_connection
57
+ http.request(request)
58
+ end
59
+ ensure
60
+ release_connection(http)
33
61
  end
34
62
 
35
63
  def new_http
@@ -1,3 +1,3 @@
1
1
  module RorVsWild
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  end
data/rorvswild.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Alexis Bernard"]
10
10
  spec.email = ["alexis@bernard.io"]
11
11
  spec.summary = "Ruby on Rails app monitoring"
12
- spec.description = "Performances & quality insights for rails developers."
12
+ spec.description = "Performances and quality insights for rails developers."
13
13
  spec.homepage = "https://www.rorvswild.com"
14
14
  spec.license = "MIT"
15
15
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rorvswild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Bernard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-22 00:00:00.000000000 Z
11
+ date: 2017-07-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Performances & quality insights for rails developers.
13
+ description: Performances and quality insights for rails developers.
14
14
  email:
15
15
  - alexis@bernard.io
16
16
  executables: