active_record_mutex 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +8 -1
- data/Rakefile +1 -1
- data/active_record_mutex.gemspec +4 -4
- data/lib/active_record/database_mutex/version.rb +1 -1
- data/lib/active_record/database_mutex.rb +20 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 337ab2cfb637dc992dda05b67bc12098b0d8d7266591dc741d4918dbb3238aee
|
4
|
+
data.tar.gz: e812c787de8cb82696027803eafa426793af334d4c1d847c9956473a7d1faf20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8cb37ec99b0a52267f964b032b8f061801bef3000a11d355af5cddef3d5f075c471bd51e3fa79310136cbc53b3cd0376c293a501363b4f48f979fc774f03efc
|
7
|
+
data.tar.gz: 1418b58e067e151bb33e92cdd7beb215cb3fdce4ea9f7439e34ae6315b452c80d9e0cafa5f368f399ec2abb7d48c0479a1a233b1fc01f4ff364043042647faa1
|
data/CHANGES.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
-
## 2024-10-
|
3
|
+
## 2024-10-16 v3.1.0
|
4
|
+
|
5
|
+
* Changes for **3.1.0**:
|
6
|
+
* Implemented `all_mutexes` method in ActiveRecord::DatabaseMutex
|
7
|
+
* Added `MutexInfo` class as a subclass of OpenStruct
|
8
|
+
* Updated `active_record_mutex.gemspec` to use **0.6** version of `ostruct`
|
9
|
+
* Removed `tins` dependency
|
4
10
|
|
11
|
+
## 2024-10-15 v3.0.0
|
5
12
|
|
6
13
|
### Major Enhancements
|
7
14
|
|
data/Rakefile
CHANGED
@@ -21,7 +21,7 @@ GemHadar do
|
|
21
21
|
|
22
22
|
dependency 'mysql2', '~> 0.3'
|
23
23
|
dependency 'activerecord', '>= 4.0'
|
24
|
-
dependency '
|
24
|
+
dependency 'ostruct', '~> 0.6'
|
25
25
|
development_dependency 'all_images', '~> 0.6'
|
26
26
|
development_dependency 'test-unit', '~> 3.0'
|
27
27
|
development_dependency 'debug'
|
data/active_record_mutex.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: active_record_mutex 3.
|
2
|
+
# stub: active_record_mutex 3.1.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "active_record_mutex".freeze
|
6
|
-
s.version = "3.
|
6
|
+
s.version = "3.1.0".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Florian Frank".freeze]
|
11
|
-
s.date = "2024-10-
|
11
|
+
s.date = "2024-10-16"
|
12
12
|
s.description = "Mutex that can be used to synchronise ruby processes via an ActiveRecord datababase connection. (Only Mysql is supported at the moment.)".freeze
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.extra_rdoc_files = ["README.md".freeze, "lib/active_record/database_mutex.rb".freeze, "lib/active_record/database_mutex/implementation.rb".freeze, "lib/active_record/database_mutex/version.rb".freeze, "lib/active_record/mutex.rb".freeze, "lib/active_record_mutex.rb".freeze]
|
@@ -29,5 +29,5 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
|
30
30
|
s.add_runtime_dependency(%q<mysql2>.freeze, ["~> 0.3".freeze])
|
31
31
|
s.add_runtime_dependency(%q<activerecord>.freeze, [">= 4.0".freeze])
|
32
|
-
s.add_runtime_dependency(%q<
|
32
|
+
s.add_runtime_dependency(%q<ostruct>.freeze, ["~> 0.6".freeze])
|
33
33
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
require 'active_record/database_mutex/version'
|
3
3
|
require 'active_record/database_mutex/implementation'
|
4
|
+
require 'ostruct'
|
4
5
|
|
5
6
|
module ActiveRecord
|
6
7
|
# This module is mixed into ActiveRecord::Base to provide the mutex methods
|
@@ -29,6 +30,11 @@ module ActiveRecord
|
|
29
30
|
# lock file permissions problems.
|
30
31
|
class MutexSystemError < MutexError; end
|
31
32
|
|
33
|
+
# The MutexInfo class is a subclass of OpenStruct, serving as a wrapper for
|
34
|
+
# information related to database mutexes. It allows dynamic attribute
|
35
|
+
# access.
|
36
|
+
MutexInfo = Class.new OpenStruct
|
37
|
+
|
32
38
|
def self.included(modul)
|
33
39
|
modul.instance_eval do
|
34
40
|
extend ClassMethods
|
@@ -59,6 +65,20 @@ module ActiveRecord
|
|
59
65
|
def mutex
|
60
66
|
@mutex ||= Implementation.new(name: mutex_name)
|
61
67
|
end
|
68
|
+
|
69
|
+
# The all_mutexes method returns an array of MutexInfo objects
|
70
|
+
# representing all mutexes currently held by database connections. The
|
71
|
+
# MutexInfo#OBJECT_NAME is the
|
72
|
+
# {ActiveRecord::DatabaseMutex::Implementation#internal_name}.
|
73
|
+
#
|
74
|
+
# @return [Array] An array of MutexInfo objects.
|
75
|
+
def all_mutexes
|
76
|
+
connection.select_all(<<~EOT).map { MutexInfo.new(_1) }
|
77
|
+
SELECT * FROM performance_schema.metadata_locks
|
78
|
+
WHERE OBJECT_TYPE = 'USER LEVEL LOCK'
|
79
|
+
AND OBJECT_NAME LIKE "$%"
|
80
|
+
EOT
|
81
|
+
end
|
62
82
|
end
|
63
83
|
|
64
84
|
# The mutex method returns an instance of
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_mutex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
@@ -109,19 +109,19 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '4.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: ostruct
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '0.6'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '0.6'
|
125
125
|
description: Mutex that can be used to synchronise ruby processes via an ActiveRecord
|
126
126
|
datababase connection. (Only Mysql is supported at the moment.)
|
127
127
|
email: flori@ping.de
|