pg_lock 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -0
- data/README.md +6 -0
- data/lib/pg_lock/locket.rb +7 -3
- data/lib/pg_lock/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e285d50b50c70bd26a8e9ce0047cb874450ebc27dc5db28c903ef613540ecaed
|
4
|
+
data.tar.gz: 8a167c46ae260ac9b84e0dd442f821a7d3a9894a4a72f206cb5fd669fcbf4594
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23e058530b6b4029df92d8733ab7828753360c85092113a1dac14afab03ff8de6a1c926c8399a7f6833811b3963febd75bb1aeaefdfb8827ab3e44c13964e7e4
|
7
|
+
data.tar.gz: 7346e5463867c3a5755203c6c8e397e863d1d2756eeda5db4614dc525693d758270e02a9bb4b6ec8e686565410cec011f7be1657d480f5fcf1d35314bb0366a2
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -182,6 +182,12 @@ Where `DB` is to be your database connection.
|
|
182
182
|
|
183
183
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
184
184
|
|
185
|
+
To run tests you'll need a database:
|
186
|
+
|
187
|
+
```
|
188
|
+
$ createdb pg_lock_test
|
189
|
+
```
|
190
|
+
|
185
191
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
186
192
|
|
187
193
|
## Contributing
|
data/lib/pg_lock/locket.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
class PgLock
|
2
2
|
# Holds the logic to aquire a lock and parse if locking was successful
|
3
3
|
class Locket
|
4
|
+
TRUE_VALUES = [true, "t"].freeze
|
5
|
+
|
4
6
|
attr_accessor :args, :connection
|
5
7
|
def initialize(connection, lock_args)
|
6
8
|
self.connection = connection
|
@@ -18,13 +20,13 @@ class PgLock
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def aquired?
|
21
|
-
@lock[0]["pg_try_advisory_lock"]
|
23
|
+
TRUE_VALUES.include?(@lock[0]["pg_try_advisory_lock"])
|
22
24
|
rescue
|
23
25
|
false
|
24
26
|
end
|
25
27
|
|
26
28
|
def active?
|
27
|
-
connection.exec(<<-eos, args).getvalue(0,0)
|
29
|
+
active = connection.exec(<<-eos, args).getvalue(0,0)
|
28
30
|
SELECT granted
|
29
31
|
FROM pg_locks
|
30
32
|
WHERE locktype = 'advisory' AND
|
@@ -33,6 +35,8 @@ class PgLock
|
|
33
35
|
classid = $1 AND
|
34
36
|
objid = $2
|
35
37
|
eos
|
38
|
+
|
39
|
+
TRUE_VALUES.include?(active)
|
36
40
|
end
|
37
41
|
end
|
38
|
-
end
|
42
|
+
end
|
data/lib/pg_lock/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_lock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mikehale
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pg
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.6.14
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Use Postgres advisory lock to isolate code execution across machines
|