officer 0.7.0 → 0.7.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.
data/README.markdown CHANGED
@@ -25,8 +25,8 @@ Run Officer in the background (production mode) and listen on a specific IP and
25
25
  sudo officer start -- -h 127.0.0.1 -p 9999
26
26
 
27
27
  - The server listens on 0.0.0.0:11500 by default.
28
- - All debugging and error output goes to stdout for now. The daemons gem is configured to log stdout.
29
- - The daemons gem will create a PID file in /var/run and log files in /var/log when using the 'start' option for background mode.
28
+ - All debugging and error output goes to stdout for now.
29
+ - The daemons gem will create a pid file in /var/run and redirect stdout to /var/log/officer.output when using the 'start' option for background mode.
30
30
 
31
31
  ## Ruby Client
32
32
 
@@ -95,10 +95,14 @@ Options:
95
95
 
96
96
  - Returns the internal state of all the server's connections.
97
97
 
98
+
99
+ ### Show the locks currently being held for this connection.
100
+
101
+ client.my_locks
102
+
103
+
98
104
  ## Planned Features
99
105
 
100
- - Retrieve the list of locks for the current connection.
101
- - Client: Option to abort a lock request if there is already a certain number of clients waiting for the lock.
102
106
  - Server: configure the daemons gem to allow multiple server processes to run on one box.
103
107
  - Tests
104
108
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
@@ -28,12 +28,14 @@ module Officer
28
28
  end
29
29
 
30
30
  def lock name, options={}
31
- execute :command => 'lock', :name => name_with_ns(name),
31
+ result = execute :command => 'lock', :name => name_with_ns(name),
32
32
  :timeout => options[:timeout], :queue_max => options[:queue_max]
33
+ strip_ns_from_hash result, 'name'
33
34
  end
34
35
 
35
36
  def unlock name
36
- execute :command => 'unlock', :name => name_with_ns(name)
37
+ result = execute :command => 'unlock', :name => name_with_ns(name)
38
+ strip_ns_from_hash result, 'name'
37
39
  end
38
40
 
39
41
  def with_lock name, options={}
@@ -67,6 +69,12 @@ module Officer
67
69
  execute :command => 'connections'
68
70
  end
69
71
 
72
+ def my_locks
73
+ result = execute :command => 'my_locks'
74
+ result['value'] = result['value'].map {|name| strip_ns(name)}
75
+ result
76
+ end
77
+
70
78
  private
71
79
  def connect
72
80
  raise AlreadyConnectedError if @socket
@@ -93,6 +101,15 @@ module Officer
93
101
  def name_with_ns name
94
102
  @namespace ? "#{@namespace}:#{name}" : name
95
103
  end
104
+
105
+ def strip_ns name
106
+ @namespace ? name.gsub(Regexp.new("^#{@namespace}:"), '') : name
107
+ end
108
+
109
+ def strip_ns_from_hash hash, key
110
+ hash[key] = strip_ns(hash[key])
111
+ hash
112
+ end
96
113
  end
97
114
 
98
115
  end
@@ -126,5 +126,14 @@ module Officer
126
126
  Officer::LockStore.instance.connections @connection
127
127
  end
128
128
  end
129
+
130
+ class MyLocks < Base
131
+ register
132
+
133
+ def execute
134
+ Officer::LockStore.instance.my_locks @connection
135
+ end
136
+ end
137
+
129
138
  end
130
139
  end
@@ -81,6 +81,10 @@ module Officer
81
81
  def queue_maxed name
82
82
  send_result 'queue_maxed', :name => name
83
83
  end
84
+
85
+ def my_locks names
86
+ send_result 'my_locks', :value => names
87
+ end
84
88
  end
85
89
 
86
90
  class Connection < EventMachine::Protocols::LineAndTextProtocol
@@ -140,11 +140,16 @@ module Officer
140
140
  connections = {}
141
141
 
142
142
  @connections.each do |conn, names|
143
- connections[conn.to_host_s] = names
143
+ connections[conn.to_host_s] = names.to_a
144
144
  end
145
145
 
146
146
  connection.connections connections
147
147
  end
148
+
149
+ def my_locks connection
150
+ my_locks = @connections[connection] ? @connections[connection].to_a : []
151
+ connection.locks my_locks
152
+ end
148
153
  end
149
154
 
150
155
  end
data/officer.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{officer}
8
- s.version = "0.7.0"
8
+ s.version = "0.7.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chad Remesch"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: officer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Remesch