semian 0.10.3 → 0.11.1

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: 1f7dfa0e1508d5754a7e551d3930645473a39de58c2c32a01b1eb1e5e6715780
4
- data.tar.gz: f51263595c18f0d6f240d01c75caaf64e00e7e85bfb268d6b0f0c27cf0b59909
3
+ metadata.gz: 972ddce3e9ba74d79ff8d6fd349324a02c1fb9d92f83dcb49ef8afa711d98421
4
+ data.tar.gz: 2a2b587fe0c799b069a151a9fafb6ec21a67ee4454d0d5cc98e9016ade94daee
5
5
  SHA512:
6
- metadata.gz: a37851110c28d95b1c057d5cfae91c9b6a5998449c248cec4940e52d32b4d4af7d9587570ef574583032fbbce078b062f6d16a8b9382c46331855120352f2a48
7
- data.tar.gz: 41ae095478be0f4761243a6ac4c2a54b9ec0488aea23156d9b80756cb449cbe73863d2814bf28d3f018cd4f4e23320ce184b169af681db27417df54fdd5dcae7
6
+ metadata.gz: 5a9605eb8233e937660a7fb5714e9c8f5461a4f4d22f60dc7427902dcc9e0812cd2c8149376426b8d654f62649badc55cb6665c40435feec1010bd6af0c0f52e
7
+ data.tar.gz: 5f049456ad6f460afcaeca9a7b55471df7f185f220eb050fa9fd6a421b41311b20f9bbf2afd0a4eb829ac929b373379fa25010bcf97a478418b592edb460bd45
@@ -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, :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,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
@@ -79,22 +79,22 @@ module Semian
79
79
  raw_semian_options.nil?
80
80
  end
81
81
 
82
- def request_response(*)
82
+ def request_response(*, **)
83
83
  return super if disabled?
84
84
  acquire_semian_resource(adapter: :grpc, scope: :request_response) { super }
85
85
  end
86
86
 
87
- def client_streamer(*)
87
+ def client_streamer(*, **)
88
88
  return super if disabled?
89
89
  acquire_semian_resource(adapter: :grpc, scope: :client_streamer) { super }
90
90
  end
91
91
 
92
- def server_streamer(*)
92
+ def server_streamer(*, **)
93
93
  return super if disabled?
94
94
  acquire_semian_resource(adapter: :grpc, scope: :server_streamer) { super }
95
95
  end
96
96
 
97
- def bidi_streamer(*)
97
+ def bidi_streamer(*, **)
98
98
  return super if disabled?
99
99
  acquire_semian_resource(adapter: :grpc, scope: :bidi_streamer) { super }
100
100
  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,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.3'
2
+ VERSION = '0.11.1'
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.3
4
+ version: 0.11.1
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-25 00:00:00.000000000 Z
13
+ date: 2020-12-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake-compiler