semian 0.11.3 → 0.11.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: b867496c18269ed172e3d5644e6534b043a7441c34a3ec4a619534a28b03f11d
4
- data.tar.gz: '09819744aa4b11f204a275ee594da9bf3e0d3b66a568ae7aef6d40e6605d5f0d'
3
+ metadata.gz: e136dd51d96e89f74e2ea3b4d838a86a265dd097c44c61601daa35dbdf60aba0
4
+ data.tar.gz: 9f42e7eba02dc6f94547d5a8c98ace41672abc9c4ec4ce093c5c8e4c160163a2
5
5
  SHA512:
6
- metadata.gz: 5b0599ce2ebc8c86212f455b3383cdb2307015d84af592e8ce6971d60da57886706a02745121bd0df3249342d5ac6113ab87bc6bcebea2391dd594b2001767b6
7
- data.tar.gz: 7432a79d19cc7583f6152355e851922faa19668349f05ff52e78f78cab245079d2f3da964b8dc162522b98f88391971adafcf8baee3559edaddfcc6da8e1bd39
6
+ metadata.gz: dd3861895b3aaf7de70a693c55276d9fc290cfd51a0460491759d106e0a9b9ea1d72bfbb7c3d31b7cf44bdbde3d2c7ce28742a25032375432c570aef325164da
7
+ data.tar.gz: 6cad2df1f48a514ee8b0122ce1b15fa9c6af84c76dfa0b435205086f6fd1d70d60c87f00eb33282caffab8bafb4500d5a099e8a4a599d3905064d6f89e555d4b
@@ -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:
@@ -43,6 +43,14 @@ module Semian
43
43
  ::SystemCallError, # includes ::Errno::EINVAL, ::Errno::ECONNRESET, ::Errno::ECONNREFUSED, ::Errno::ETIMEDOUT, and more
44
44
  ].freeze # Net::HTTP can throw many different errors, this tries to capture most of them
45
45
 
46
+ module ClassMethods
47
+ def new(*args, semian: true)
48
+ http = super(*args)
49
+ http.instance_variable_set(:@semian_enabled, semian)
50
+ http
51
+ end
52
+ end
53
+
46
54
  class << self
47
55
  attr_accessor :exceptions
48
56
  attr_reader :semian_configuration
@@ -75,7 +83,7 @@ module Semian
75
83
  end
76
84
 
77
85
  def disabled?
78
- raw_semian_options.nil?
86
+ raw_semian_options.nil? || @semian_enabled == false
79
87
  end
80
88
 
81
89
  def connect
@@ -115,3 +123,4 @@ module Semian
115
123
  end
116
124
 
117
125
  Net::HTTP.prepend(Semian::NetHTTP)
126
+ Net::HTTP.singleton_class.prepend(Semian::NetHTTP::ClassMethods)
data/lib/semian/redis.rb CHANGED
@@ -16,6 +16,14 @@ class Redis
16
16
  include ::Semian::AdapterError
17
17
  end
18
18
 
19
+ class ConnectionError < Redis::BaseConnectionError
20
+ # A Connection Reset is a fast failure and we don't want to track these errors in
21
+ # semian
22
+ def marks_semian_circuits?
23
+ message != "Connection lost (ECONNRESET)"
24
+ end
25
+ end
26
+
19
27
  ResourceBusyError = Class.new(SemianError)
20
28
  CircuitOpenError = Class.new(SemianError)
21
29
  ResolveError = Class.new(SemianError)
@@ -1,3 +1,3 @@
1
1
  module Semian
2
- VERSION = '0.11.3'
2
+ VERSION = '0.11.7'
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
  #
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.3
4
+ version: 0.11.7
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: 2021-02-02 00:00:00.000000000 Z
13
+ date: 2022-01-12 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