semian 0.21.3 → 0.22.0.RC.1

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: 86eb12415dc2e681f9a24df85bc1b8b6498da3833e50d217bc1e69e2c8696cf0
4
- data.tar.gz: c919fbbf5eb02a44ac38c914187215559a794f007f8ea5e33ff91a9ebd13b3f9
3
+ metadata.gz: afd87705b68966cef884eeeb1d5df4d052eeb86f2ff7d43c9499435795341461
4
+ data.tar.gz: 911a0772662b81e21dcb475c9b981ceb0fbaeadf26edbbca70ab8adbf5be4068
5
5
  SHA512:
6
- metadata.gz: 5cebfd79bbaad7b77f17399c745674dd1b850fd8742e5a87af320326bf77273979c2cceec2fef292f6779f6100b088aab22d7aed9be80f46a7b5eadb2c6790c6
7
- data.tar.gz: 1d093b46109d85c20ace2570e652608f6cba7cb3d18a79443f9dbca002f479c208d2ab45026355b6637ac0b506c906ea9d0379eaee62fe1f2eff5a14152be5c5
6
+ metadata.gz: 8edb70d967cb15e12b919b3a7e6585f98848e2d569683d590d2d37e32eb57b65cd9f425931a3bf1575d91fc6c50e9d43901340cb33a34a671a585956b947514f
7
+ data.tar.gz: b880f4f52891cbc4fd3d97221053bddc741aa72a98b986826b8ca08454c73ccbe714cff311966387f40b83e2f48a6d2db4ddf23407ff275e55bfb8c1730b5673
@@ -63,6 +63,8 @@ semian_resource_acquire(int argc, VALUE *argv, VALUE self)
63
63
  if (res.error != 0) {
64
64
  if (res.error == EAGAIN) {
65
65
  rb_raise(eTimeout, "timed out waiting for resource '%s'", res.name);
66
+ } else if (res.error == EINVAL && get_semaphore(res.sem_id) == -1 && errno == ENOENT) {
67
+ rb_raise(eSemaphoreMissing, "semaphore array '%s' no longer exists", res.name);
66
68
  } else {
67
69
  raise_semian_syscall_error("semop()", res.error);
68
70
  }
data/ext/semian/semian.c CHANGED
@@ -1,6 +1,6 @@
1
1
  #include "semian.h"
2
2
 
3
- VALUE eSyscall, eTimeout, eInternal;
3
+ VALUE eSyscall, eTimeout, eInternal, eSemaphoreMissing;
4
4
 
5
5
  void Init_semian()
6
6
  {
@@ -46,6 +46,17 @@ void Init_semian()
46
46
  eInternal = rb_const_get(cSemian, rb_intern("InternalError"));
47
47
  rb_global_variable(&eInternal);
48
48
 
49
+ /* Document-class: Semian::SemaphoreMissingError
50
+ *
51
+ * Indicates that some time after initialization, a semaphore array was no longer
52
+ * present when we tried to access it. This can happen because semaphores were
53
+ * deleted using the <code>ipcrm</code> command line tool, the
54
+ * <code>semctl(..., IPC_RMID)</code> syscall, or systemd's <code>RemoveIPC</code>
55
+ * feature.
56
+ */
57
+ eSemaphoreMissing = rb_const_get(cSemian, rb_intern("SemaphoreMissingError"));
58
+ rb_global_variable(&eSemaphoreMissing);
59
+
49
60
  rb_define_alloc_func(cResource, semian_resource_alloc);
50
61
  rb_define_method(cResource, "initialize_semaphore", semian_resource_initialize, 5);
51
62
  rb_define_method(cResource, "acquire", semian_resource_acquire, -1);
@@ -66,7 +66,7 @@ enum SEMINDEX_ENUM {
66
66
  FOREACH_SEMINDEX(GENERATE_ENUM)
67
67
  };
68
68
 
69
- extern VALUE eSyscall, eTimeout, eInternal;
69
+ extern VALUE eSyscall, eTimeout, eInternal, eSemaphoreMissing;
70
70
 
71
71
  // Helper for syscall verbose debugging
72
72
  void
data/lib/semian/mysql2.rb CHANGED
@@ -28,6 +28,8 @@ module Semian
28
28
  /Too many connections/i,
29
29
  /closed MySQL connection/i,
30
30
  /Timeout waiting for a response/i,
31
+ /No matching servers with free connections/i,
32
+ /Max connect timeout reached while reaching hostgroup/i,
31
33
  )
32
34
 
33
35
  ResourceBusyError = ::Mysql2::ResourceBusyError
@@ -136,7 +138,8 @@ module Semian
136
138
 
137
139
  def raw_semian_options
138
140
  return query_options[:semian] if query_options.key?(:semian)
139
- return query_options["semian"] if query_options.key?("semian")
141
+
142
+ query_options["semian"] if query_options.key?("semian")
140
143
  end
141
144
  end
142
145
  end
data/lib/semian/redis.rb CHANGED
@@ -151,7 +151,8 @@ module Semian
151
151
 
152
152
  def raw_semian_options
153
153
  return options[:semian] if options.key?(:semian)
154
- return options["semian"] if options.key?("semian")
154
+
155
+ options["semian"] if options.key?("semian")
155
156
  end
156
157
 
157
158
  def raise_if_out_of_memory(reply)
@@ -33,19 +33,25 @@ class RedisClient
33
33
  CircuitOpenError = Class.new(SemianError)
34
34
 
35
35
  module SemianConfig
36
- attr_reader :raw_semian_options
37
-
38
36
  def initialize(semian: nil, **kwargs)
39
37
  super(**kwargs)
40
38
 
41
39
  @raw_semian_options = semian
42
40
  end
43
41
 
42
+ def raw_semian_options
43
+ @raw_semian_options.respond_to?(:call) ? @raw_semian_options.call(host, port) : @raw_semian_options
44
+ end
45
+
44
46
  def semian_identifier
45
- @semian_identifier ||= begin
47
+ return @semian_identifier if @semian_identifier
48
+
49
+ identifier = begin
46
50
  name = (semian_options && semian_options[:name]) || "#{host}:#{port}/#{db}"
47
51
  :"redis_#{name}"
48
52
  end
53
+ @semian_identifier = identifier unless semian_options && semian_options[:dynamic]
54
+ identifier
49
55
  end
50
56
 
51
57
  define_method(:semian_options, Semian::Adapter.instance_method(:semian_options))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Semian
4
- VERSION = "0.21.3"
4
+ VERSION = "0.22.0.RC.1"
5
5
  end
data/lib/semian.rb CHANGED
@@ -100,6 +100,7 @@ module Semian
100
100
  TimeoutError = Class.new(BaseError)
101
101
  InternalError = Class.new(BaseError)
102
102
  OpenCircuitError = Class.new(BaseError)
103
+ SemaphoreMissingError = Class.new(BaseError)
103
104
 
104
105
  attr_accessor :maximum_lru_size, :minimum_lru_time, :default_permissions, :namespace
105
106
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.3
4
+ version: 0.22.0.RC.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Francis
8
8
  - Simon Eskildsen
9
9
  - Dale Hamel
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-02-19 00:00:00.000000000 Z
13
+ date: 2024-07-02 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: |2
16
16
  A Ruby C extention that is used to control access to shared resources
@@ -64,7 +64,7 @@ metadata:
64
64
  documentation_uri: https://github.com/Shopify/semian
65
65
  homepage_uri: https://github.com/Shopify/semian
66
66
  source_code_uri: https://github.com/Shopify/semian
67
- post_install_message:
67
+ post_install_message:
68
68
  rdoc_options: []
69
69
  require_paths:
70
70
  - lib
@@ -72,15 +72,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 2.7.0
76
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
- rubygems_version: 3.5.6
83
- signing_key:
82
+ rubygems_version: 3.5.14
83
+ signing_key:
84
84
  specification_version: 4
85
85
  summary: Bulkheading for Ruby with SysV semaphores
86
86
  test_files: []