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 +4 -4
- data/ext/semian/semian.c +5 -0
- data/ext/semian/sysv_semaphores.h +1 -1
- data/lib/semian.rb +4 -3
- data/lib/semian/mysql2.rb +3 -3
- data/lib/semian/resource.rb +1 -1
- data/lib/semian/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41ea178ba2c9b67cc36eb6f18c3c80a7a981916b83b2b43c22b51131c2570742
|
4
|
+
data.tar.gz: d2855772d339c16d2ff85b55d7372b962ec03e71542b81ed1c328a6687bdac9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4137c69475d6e40331bf63c16a815933329c53908465b7c8b7090069c7121516a5f02a3b1acc7b336548d5651922bc72ad2fcdde042a14b3a73a7d5bfadf8059
|
7
|
+
data.tar.gz: 49ebd343a8b45217ef5969123cd829b61bebcd9828962435003aab83a95010b2b886a8209f27a081132a4d542431b26aba8f4eca7478034daa1424242da1e0a5
|
data/ext/semian/semian.c
CHANGED
@@ -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);
|
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
|
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] ||
|
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
|
data/lib/semian/mysql2.rb
CHANGED
@@ -37,9 +37,9 @@ module Semian
|
|
37
37
|
DEFAULT_PORT = 3306
|
38
38
|
|
39
39
|
QUERY_WHITELIST = Regexp.union(
|
40
|
-
/\A
|
41
|
-
/\A
|
42
|
-
/\A
|
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
|
data/lib/semian/resource.rb
CHANGED
@@ -9,7 +9,7 @@ module Semian
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def initialize(name, tickets: nil, quota: nil, permissions:
|
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
|
data/lib/semian/version.rb
CHANGED
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.
|
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-
|
13
|
+
date: 2020-12-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake-compiler
|