mongo_mutex 0.0.1 → 0.0.2
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/bin/mongo_mutex +9 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 325233eda18ece7e567860ca0e662ffa6468ceab
|
4
|
+
data.tar.gz: d08b991080728f0535fa3d29789fc16f88bfe803
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 538a966568c7dbd2e99cddbda7bb03793d4ce715ee9a9fc8c02d7277aab736bf35c4dbee3722753abd1f920ad02e7eb01e3dea7a7842f62769b9998016761914
|
7
|
+
data.tar.gz: 0cfbde88005d9d89e5c4bd4a5cd6e73167815e2fb2cb8a8e45ec99cdb431ace891bbd44f5f03a609ba9e307f391fcc8f7e6dc3dbb12b54c4f05a6f9dc04dd428
|
data/bin/mongo_mutex
CHANGED
@@ -15,12 +15,11 @@ collection_name = 'mutex'
|
|
15
15
|
lock_name = nil
|
16
16
|
locker_name = Socket.gethostname
|
17
17
|
block_on_complete = nil
|
18
|
-
|
19
|
-
|
20
|
-
}
|
18
|
+
command = nil
|
19
|
+
options = {}
|
21
20
|
|
22
21
|
OptionParser.new do |opts|
|
23
|
-
opts.on('-
|
22
|
+
opts.on('-f CONFIG_FILE', 'Path to config file containing mongodb connection uri') do |filename|
|
24
23
|
hosts = File.readlines(filename).map(&:strip).reject(&:empty?)
|
25
24
|
end
|
26
25
|
|
@@ -47,16 +46,20 @@ OptionParser.new do |opts|
|
|
47
46
|
opts.on('--block N', Integer, 'On success, block other nodes from executing for N seconds') do |block_time|
|
48
47
|
block_on_complete = block_time
|
49
48
|
end
|
49
|
+
|
50
|
+
opts.on('-c COMMAND', '--command', 'Command to execute') do |cmd|
|
51
|
+
command = cmd
|
52
|
+
end
|
53
|
+
|
50
54
|
end.parse!
|
51
55
|
|
56
|
+
raise OptionParser::MissingArgument.new('Command is mandatory') unless command
|
52
57
|
raise OptionParser::MissingArgument.new('Lock name is mandatory') unless lock_name
|
53
58
|
|
54
59
|
module Enumerable
|
55
60
|
alias :all_are? :all?
|
56
61
|
end
|
57
62
|
|
58
|
-
command = ARGV.join(' ')
|
59
|
-
|
60
63
|
collection = Mongo::Client.new(hosts, :database => database_name)[collection_name]
|
61
64
|
mutex = MongoMutex::Mutex.new(collection, lock_name, locker_name, options)
|
62
65
|
complete_mutex = MongoMutex::Mutex.new(collection, "#{lock_name}_complete", locker_name, options.merge(:lock_retention_timeout => block_on_complete)) if block_on_complete
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_mutex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Dahl
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongo
|