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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/mongo_mutex +9 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a899ddda53434cc9bcb3160e4cd2d4ab0cf6a8d
4
- data.tar.gz: 60fc670259bba255522221e4ee73db1b498773ae
3
+ metadata.gz: 325233eda18ece7e567860ca0e662ffa6468ceab
4
+ data.tar.gz: d08b991080728f0535fa3d29789fc16f88bfe803
5
5
  SHA512:
6
- metadata.gz: af3c6349d873aa41ff186190f14d5e8c7f688171daa4a97614e62fb438772980b1bc578bc0335d1920b5741761fe4d264d8f239d0bb5faf90e72d8c27b8a56c8
7
- data.tar.gz: 59f6faa7f7d3a9b2ec12e35104c55bcb793e2a56f0bb561ad9ff907f7417d18f46a0036b092f588082f470afb806dfd82b9b31e801dc03aa2a8962eae11fde57
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
- options = {
19
- # logger: Logger.new(STDOUT)
20
- }
18
+ command = nil
19
+ options = {}
21
20
 
22
21
  OptionParser.new do |opts|
23
- opts.on('-c CONFIG_FILE', 'Path to config file containing mongodb connection uri') do |filename|
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.1
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-11-30 00:00:00.000000000 Z
12
+ date: 2015-12-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongo