semian 0.10.6 → 0.11.4

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: b54ee93c46832142977d1befbd48c6e76e20992573eee798056810cfca6cc2a4
4
- data.tar.gz: a9a3f804b0aebf6a794c085fc11fb2ea612e876e13d8d6ace6cf3fe4c095e631
3
+ metadata.gz: c988cdfecca00a6df20c29238464aa7abf607ff59064612015616b38a69e8ac0
4
+ data.tar.gz: 52682cddc76221d7e09c4d6e9c1074754afc2c648fcb7f19ffea05dfaff9a8f1
5
5
  SHA512:
6
- metadata.gz: f388523a165f4325bb517d801b804a81636008afb6f0c0951be8a4b108323b7621ebf3444925befc2cfd0ac16fdbfc442cb9ec826e19e17ef9aab50769121294
7
- data.tar.gz: 043bbc5dad551ca00ded71a4026121afbb01f22cda73d526470fe63c1077f590db1ed64449c23f2e2d6b5f735d87e89c266a638f8deff191b944eb98d1f5f361
6
+ metadata.gz: e4c6a0b2e33e13abc45641774b7d79faf5bec85241a5704cb1cd9180be5ee99b726b769bf9bf64d77528584fe13b9b875f92c4a04d4f0ef32dd0f1875ee1b3c9
7
+ data.tar.gz: 75a3f87b1986daac3d4f4528aea225ff30c02637b693c668f6bd799506193c3d4517327f20a194b9251412a8c7c6322b8343656867b64407f22459c93e6dc8e2
@@ -1,5 +1,10 @@
1
1
  #include "resource.h"
2
2
 
3
+ // Ruby variables
4
+ ID id_wait_time;
5
+ ID id_timeout;
6
+ int system_max_semaphore_count;
7
+
3
8
  static VALUE
4
9
  cleanup_semian_resource_acquire(VALUE self);
5
10
 
@@ -10,9 +10,9 @@ Functions here are associated with rubyland operations.
10
10
  #include "sysv_semaphores.h"
11
11
 
12
12
  // Ruby variables
13
- ID id_wait_time;
14
- ID id_timeout;
15
- int system_max_semaphore_count;
13
+ extern ID id_wait_time;
14
+ extern ID id_timeout;
15
+ extern int system_max_semaphore_count;
16
16
 
17
17
  /*
18
18
  * call-seq:
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
 
@@ -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.6'
2
+ VERSION = '0.11.4'
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.6
4
+ version: 0.11.4
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-11-05 00:00:00.000000000 Z
13
+ date: 2021-04-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake-compiler