semian 0.11.1 → 0.11.5

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: 972ddce3e9ba74d79ff8d6fd349324a02c1fb9d92f83dcb49ef8afa711d98421
4
- data.tar.gz: 2a2b587fe0c799b069a151a9fafb6ec21a67ee4454d0d5cc98e9016ade94daee
3
+ metadata.gz: c0651ee42cbac47393177d1c80e6903e61dd226ce0da0adf57ee720c687bd2a0
4
+ data.tar.gz: 844843bbf8c005b4dae38529f2b51f16246c3c64b6e31e94648c3e4c3303f74c
5
5
  SHA512:
6
- metadata.gz: 5a9605eb8233e937660a7fb5714e9c8f5461a4f4d22f60dc7427902dcc9e0812cd2c8149376426b8d654f62649badc55cb6665c40435feec1010bd6af0c0f52e
7
- data.tar.gz: 5f049456ad6f460afcaeca9a7b55471df7f185f220eb050fa9fd6a421b41311b20f9bbf2afd0a4eb829ac929b373379fa25010bcf97a478418b592edb460bd45
6
+ metadata.gz: c680195c4c8738df4bf06c71264f37a1a182dc680ae9186834872cac9ebd75949d5cc66ca839f199afbaf1cbf45c11d65d76b34a27717dbbd85962be23594753
7
+ data.tar.gz: e630c03e61c1224661cae64c6ebcaf0e5a706ae08262fa4659054519216c849a6de5b2777ca4069e76a5e87bad2c740125e10138e58034e2d734b16e52f481cc
@@ -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
 
@@ -267,8 +272,11 @@ check_permissions_arg(VALUE permissions)
267
272
  static void
268
273
  check_tickets_xor_quota_arg(VALUE tickets, VALUE quota)
269
274
  {
270
- if ((TYPE(tickets) == T_NIL && TYPE(quota) == T_NIL) ||(TYPE(tickets) != T_NIL && TYPE(quota) != T_NIL)){
271
- rb_raise(rb_eArgError, "Must pass exactly one of ticket or quota");
275
+ if (tickets == Qnil && quota == Qnil) {
276
+ rb_raise(rb_eArgError, "Semian configuration require either the :ticket or :quota parameter, you provided neither");
277
+ }
278
+ if (tickets != Qnil && quota != Qnil) {
279
+ rb_raise(rb_eArgError, "Semian configuration require either the :ticket or :quota parameter, you provided both");
272
280
  }
273
281
  }
274
282
 
@@ -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:
@@ -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
 
@@ -61,6 +61,11 @@ module Semian
61
61
  end
62
62
  end
63
63
 
64
+ def initialize(*args, semian: true)
65
+ super(*args)
66
+ @semian_enabled = semian
67
+ end
68
+
64
69
  Semian::NetHTTP.reset_exceptions
65
70
 
66
71
  def raw_semian_options
@@ -75,7 +80,7 @@ module Semian
75
80
  end
76
81
 
77
82
  def disabled?
78
- raw_semian_options.nil?
83
+ raw_semian_options.nil? || @semian_enabled == false
79
84
  end
80
85
 
81
86
  def connect
@@ -1,3 +1,3 @@
1
1
  module Semian
2
- VERSION = '0.11.1'
2
+ VERSION = '0.11.5'
3
3
  end
data/lib/semian.rb CHANGED
@@ -46,7 +46,7 @@ require 'semian/lru_hash'
46
46
  # resource the time to recover. If `error_threshold` errors happen in the span of `error_timeout`
47
47
  # then the circuit will be opened and every attempt to acquire the resource will immediately fail.
48
48
  #
49
- # Once in open state, after `error_timeout` is elapsed, the ciruit will transition in the half-open state.
49
+ # Once in open state, after `error_timeout` is elapsed, the circuit will transition in the half-open state.
50
50
  # In that state a single error will fully re-open the circuit, and the circuit will transition back to the closed
51
51
  # state only after the resource is acquired `success_threshold` consecutive times.
52
52
  #
@@ -62,7 +62,7 @@ require 'semian/lru_hash'
62
62
  #
63
63
  # After 3 failures in the span of 10 seconds the circuit will be open.
64
64
  # After an additional 10 seconds it will transition to half-open.
65
- # And finally after 2 successulf acquisitions of the resource it will transition back to the closed state.
65
+ # And finally after 2 successful acquisitions of the resource it will transition back to the closed state.
66
66
  #
67
67
  # ===== Using a resource
68
68
  #
@@ -143,7 +143,8 @@ module Semian
143
143
  #
144
144
  # +timeout+: Default timeout in seconds. Default 0. (bulkhead)
145
145
  #
146
- # +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)
147
148
  #
148
149
  # +error_timeout+: The duration in seconds since the last error after which the error count is reset to 0.
149
150
  # (circuit breaker required)
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.11.1
4
+ version: 0.11.5
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-12-10 00:00:00.000000000 Z
13
+ date: 2021-11-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake-compiler
@@ -251,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
251
  - !ruby/object:Gem::Version
252
252
  version: '0'
253
253
  requirements: []
254
- rubygems_version: 3.0.3
254
+ rubygems_version: 3.2.20
255
255
  signing_key:
256
256
  specification_version: 4
257
257
  summary: Bulkheading for Ruby with SysV semaphores