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 +8 -4
- data/VERSION +1 -1
- data/lib/officer/client.rb +19 -2
- data/lib/officer/commands.rb +9 -0
- data/lib/officer/connection.rb +4 -0
- data/lib/officer/lock_store.rb +6 -1
- data/officer.gemspec +1 -1
- metadata +1 -1
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.
|
29
|
-
- The daemons gem will create a
|
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.
|
1
|
+
0.7.1
|
data/lib/officer/client.rb
CHANGED
@@ -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
|
data/lib/officer/commands.rb
CHANGED
data/lib/officer/connection.rb
CHANGED
data/lib/officer/lock_store.rb
CHANGED
@@ -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