semian 0.10.2 → 0.11.0

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: 747b94dcb738dc26e7ae655238860cc62fa7835a6caafa6dc2558e3731e46a18
4
- data.tar.gz: b8cd4a45387b2ca461c2ad82cdc62f623bad6b3a787e7d41d073cffcaad36f0b
3
+ metadata.gz: 41ea178ba2c9b67cc36eb6f18c3c80a7a981916b83b2b43c22b51131c2570742
4
+ data.tar.gz: d2855772d339c16d2ff85b55d7372b962ec03e71542b81ed1c328a6687bdac9e
5
5
  SHA512:
6
- metadata.gz: 419e8d66a582f959b0b8e9ec720310b02726bffcb4c64cbf14d708792a3d6e5ab71ecca02a950e8e98e3942aadc922986072f7ef4328defa40d8d537db9a23f6
7
- data.tar.gz: 111d0de5c5617e3204fb661f088eec96763cdffa73d2da69b0bd7aceb357abda087897188a92884132c6f1b9215289a9c61e60877ebead95b7957d52203f28b2
6
+ metadata.gz: 4137c69475d6e40331bf63c16a815933329c53908465b7c8b7090069c7121516a5f02a3b1acc7b336548d5651922bc72ad2fcdde042a14b3a73a7d5bfadf8059
7
+ data.tar.gz: 49ebd343a8b45217ef5969123cd829b61bebcd9828962435003aab83a95010b2b886a8209f27a081132a4d542431b26aba8f4eca7478034daa1424242da1e0a5
@@ -1,5 +1,7 @@
1
1
  #include "semian.h"
2
2
 
3
+ VALUE eSyscall, eTimeout, eInternal;
4
+
3
5
  void Init_semian()
4
6
  {
5
7
  VALUE cSemian, cResource;
@@ -22,12 +24,14 @@ void Init_semian()
22
24
  * Represents a Semian error that was caused by an underlying syscall failure.
23
25
  */
24
26
  eSyscall = rb_const_get(cSemian, rb_intern("SyscallError"));
27
+ rb_global_variable(&eSyscall);
25
28
 
26
29
  /* Document-class: Semian::TimeoutError
27
30
  *
28
31
  * Raised when a Semian operation timed out.
29
32
  */
30
33
  eTimeout = rb_const_get(cSemian, rb_intern("TimeoutError"));
34
+ rb_global_variable(&eTimeout);
31
35
 
32
36
  /* Document-class: Semian::InternalError
33
37
  *
@@ -40,6 +44,7 @@ void Init_semian()
40
44
  * the semaphore in this case.
41
45
  */
42
46
  eInternal = rb_const_get(cSemian, rb_intern("InternalError"));
47
+ rb_global_variable(&eInternal);
43
48
 
44
49
  rb_define_alloc_func(cResource, semian_resource_alloc);
45
50
  rb_define_method(cResource, "initialize_semaphore", semian_resource_initialize, 5);
@@ -63,7 +63,7 @@ enum SEMINDEX_ENUM {
63
63
  FOREACH_SEMINDEX(GENERATE_ENUM)
64
64
  };
65
65
 
66
- VALUE eSyscall, eTimeout, eInternal;
66
+ extern VALUE eSyscall, eTimeout, eInternal;
67
67
 
68
68
  // Helper for syscall verbose debugging
69
69
  void
@@ -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
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,7 +139,7 @@ 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
  #
@@ -282,7 +283,7 @@ module Semian
282
283
  bulkhead = options.fetch(:bulkhead, true)
283
284
  return unless bulkhead
284
285
 
285
- permissions = options[:permissions] || 0660
286
+ permissions = options[:permissions] || default_permissions
286
287
  timeout = options[:timeout] || 0
287
288
  Resource.new(name, tickets: options[:tickets], quota: options[:quota], permissions: permissions, timeout: timeout)
288
289
  end
@@ -37,9 +37,9 @@ module Semian
37
37
  DEFAULT_PORT = 3306
38
38
 
39
39
  QUERY_WHITELIST = Regexp.union(
40
- /\A\s*ROLLBACK/i,
41
- /\A\s*COMMIT/i,
42
- /\A\s*RELEASE\s+SAVEPOINT/i,
40
+ /\A(?:\/\*.*?\*\/)?\s*ROLLBACK/i,
41
+ /\A(?:\/\*.*?\*\/)?\s*COMMIT/i,
42
+ /\A(?:\/\*.*?\*\/)?\s*RELEASE\s+SAVEPOINT/i,
43
43
  )
44
44
 
45
45
  # The naked methods are exposed as `raw_query` and `raw_connect` for instrumentation purpose
@@ -9,7 +9,7 @@ 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
13
  if Semian.semaphores_enabled?
14
14
  initialize_semaphore(name, tickets, quota, permissions, timeout) if respond_to?(:initialize_semaphore)
15
15
  else
@@ -1,3 +1,3 @@
1
1
  module Semian
2
- VERSION = '0.10.2'
2
+ VERSION = '0.11.0'
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.2
4
+ version: 0.11.0
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-05-12 00:00:00.000000000 Z
13
+ date: 2020-12-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake-compiler