semian 0.10.5 → 0.11.3

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
  SHA256:
3
- metadata.gz: ed326cf0bc3f6b5b1ae9cb18b6170b4d47cef460883aca5c20f2f7d113403dbc
4
- data.tar.gz: e229fbdf17441a0ccb89963196fe1f4ff3a41a43e4c0be633b4164842ffbb4ed
3
+ metadata.gz: b867496c18269ed172e3d5644e6534b043a7441c34a3ec4a619534a28b03f11d
4
+ data.tar.gz: '09819744aa4b11f204a275ee594da9bf3e0d3b66a568ae7aef6d40e6605d5f0d'
5
5
  SHA512:
6
- metadata.gz: 167e750d067604930d2097fbcd98095eadcb01a4d614483dd2ed55a7bec861f602e8185d51a9f57f982e35ca66ec2d1d74bd7bed7e2180ae0210a869b0015ffc
7
- data.tar.gz: 5c4fa76a0143852aa71a838f3c2b4632f97db54485b05275ae96c5ee526ed4a3bf71bc67d695c39c53386873303fff50afdcfd3fc32af667160be1dd827609d8
6
+ metadata.gz: 5b0599ce2ebc8c86212f455b3383cdb2307015d84af592e8ce6971d60da57886706a02745121bd0df3249342d5ac6113ab87bc6bcebea2391dd594b2001767b6
7
+ data.tar.gz: 7432a79d19cc7583f6152355e851922faa19668349f05ff52e78f78cab245079d2f3da964b8dc162522b98f88391971adafcf8baee3559edaddfcc6da8e1bd39
data/lib/semian.rb CHANGED
@@ -90,9 +90,10 @@ module Semian
90
90
  InternalError = Class.new(BaseError)
91
91
  OpenCircuitError = Class.new(BaseError)
92
92
 
93
- attr_accessor :maximum_lru_size, :minimum_lru_time
93
+ attr_accessor :maximum_lru_size, :minimum_lru_time, :default_permissions, :namespace
94
94
  self.maximum_lru_size = 500
95
95
  self.minimum_lru_time = 300
96
+ self.default_permissions = 0660
96
97
 
97
98
  def issue_disabled_semaphores_warning
98
99
  return if defined?(@warning_issued)
@@ -138,11 +139,12 @@ module Semian
138
139
  # Mutually exclusive with the 'ticket' argument.
139
140
  # but the resource must have been previously registered otherwise an error will be raised. (bulkhead)
140
141
  #
141
- # +permissions+: Octal permissions of the resource. Default 0660. (bulkhead)
142
+ # +permissions+: Octal permissions of the resource. Default to +Semian.default_permissions+ (0660). (bulkhead)
142
143
  #
143
144
  # +timeout+: Default timeout in seconds. Default 0. (bulkhead)
144
145
  #
145
- # +error_threshold+: The number of errors that will trigger the circuit opening. (circuit breaker required)
146
+ # +error_threshold+: The amount of errors that must happen within error_timeout amount of time to open
147
+ # the circuit. (circuit breaker required)
146
148
  #
147
149
  # +error_timeout+: The duration in seconds since the last error after which the error count is reset to 0.
148
150
  # (circuit breaker required)
@@ -282,7 +284,7 @@ module Semian
282
284
  bulkhead = options.fetch(:bulkhead, true)
283
285
  return unless bulkhead
284
286
 
285
- permissions = options[:permissions] || 0660
287
+ permissions = options[:permissions] || default_permissions
286
288
  timeout = options[:timeout] || 0
287
289
  Resource.new(name, tickets: options[:tickets], quota: options[:quota], permissions: permissions, timeout: timeout)
288
290
  end
@@ -136,6 +136,10 @@ module Semian
136
136
  str << " success_count_threshold=#{@success_count_threshold} error_count_threshold=#{@error_count_threshold}"
137
137
  str << " error_timeout=#{@error_timeout} error_last_at=\"#{@errors.last}\""
138
138
  str << " name=\"#{@name}\""
139
+ if new_state == :open && @last_error
140
+ str << " last_error_message=#{@last_error.message.inspect}"
141
+ end
142
+
139
143
  Semian.logger.info(str)
140
144
  end
141
145
 
data/lib/semian/mysql2.rb CHANGED
@@ -25,7 +25,6 @@ module Semian
25
25
  /MySQL server has gone away/i,
26
26
  /Too many connections/i,
27
27
  /closed MySQL connection/i,
28
- /MySQL client is not connected/i,
29
28
  /Timeout waiting for a response/i,
30
29
  )
31
30
 
@@ -37,9 +36,9 @@ module Semian
37
36
  DEFAULT_PORT = 3306
38
37
 
39
38
  QUERY_WHITELIST = Regexp.union(
40
- /\A\s*ROLLBACK/i,
41
- /\A\s*COMMIT/i,
42
- /\A\s*RELEASE\s+SAVEPOINT/i,
39
+ /\A(?:\/\*.*?\*\/)?\s*ROLLBACK/i,
40
+ /\A(?:\/\*.*?\*\/)?\s*COMMIT/i,
41
+ /\A(?:\/\*.*?\*\/)?\s*RELEASE\s+SAVEPOINT/i,
43
42
  )
44
43
 
45
44
  # The naked methods are exposed as `raw_query` and `raw_connect` for instrumentation purpose
@@ -9,9 +9,15 @@ module Semian
9
9
  end
10
10
  end
11
11
 
12
- def initialize(name, tickets: nil, quota: nil, permissions: 0660, timeout: 0)
12
+ def initialize(name, tickets: nil, quota: nil, permissions: Semian.default_permissions, timeout: 0)
13
+ unless name.is_a?(String) || name.is_a?(Symbol)
14
+ raise TypeError, "name must be a string or symbol, got: #{name.class}"
15
+ end
16
+
13
17
  if Semian.semaphores_enabled?
14
- initialize_semaphore(name, tickets, quota, permissions, timeout) if respond_to?(:initialize_semaphore)
18
+ if respond_to?(:initialize_semaphore)
19
+ initialize_semaphore("#{Semian.namespace}#{name}", tickets, quota, permissions, timeout)
20
+ end
15
21
  else
16
22
  Semian.issue_disabled_semaphores_warning
17
23
  end
@@ -1,3 +1,3 @@
1
1
  module Semian
2
- VERSION = '0.10.5'
2
+ VERSION = '0.11.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.5
4
+ version: 0.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Francis
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-10-14 00:00:00.000000000 Z
13
+ date: 2021-02-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake-compiler