8888local tube = {}
8989
9090-- This check must be called from all public tube methods.
91- local function check_state ()
91+ local function check_state (method )
9292 if queue_state .get () ~= queue_state .states .RUNNING then
93- log .error ((' Queue is in %s state' ):format (queue_state .show ()))
93+ log .error ((' %s: queue is in %s state' ):format (method , queue_state .show ()))
9494 return false
9595 end
9696
9797 return true
9898end
9999
100100function tube .put (self , data , opts )
101- if not check_state () then
101+ if not check_state (" put " ) then
102102 return nil
103103 end
104104 opts = opts or {}
@@ -110,7 +110,7 @@ local conds = {}
110110local releasing_connections = {}
111111
112112function tube .take (self , timeout )
113- if not check_state () then
113+ if not check_state (" take " ) then
114114 return nil
115115 end
116116 timeout = util .time (timeout or util .TIMEOUT_INFINITY )
@@ -151,7 +151,7 @@ function tube.take(self, timeout)
151151end
152152
153153function tube .touch (self , id , delta )
154- if not check_state () then
154+ if not check_state (" touch " ) then
155155 return
156156 end
157157 if delta == nil then
@@ -177,7 +177,7 @@ function tube.touch(self, id, delta)
177177end
178178
179179function tube .ack (self , id )
180- if not check_state () then
180+ if not check_state (" ack " ) then
181181 return nil
182182 end
183183 check_task_is_taken (self .tube_id , id )
@@ -206,15 +206,15 @@ local function tube_release_internal(self, id, opts, session_uuid)
206206end
207207
208208function tube .release (self , id , opts )
209- if not check_state () then
209+ if not check_state (" release " ) then
210210 return nil
211211 end
212212 return tube_release_internal (self , id , opts )
213213end
214214
215215-- Release all tasks.
216216function tube .release_all (self )
217- if not check_state () then
217+ if not check_state (" tube " ) then
218218 return
219219 end
220220 local prefix = (' queue: [tube "%s"] ' ):format (self .name )
@@ -229,7 +229,7 @@ function tube.release_all(self)
229229end
230230
231231function tube .peek (self , id )
232- if not check_state () then
232+ if not check_state (" peek " ) then
233233 return nil
234234 end
235235 local task = self .raw :peek (id )
@@ -240,7 +240,7 @@ function tube.peek(self, id)
240240end
241241
242242function tube .bury (self , id )
243- if not check_state () then
243+ if not check_state (" bury " ) then
244244 return nil
245245 end
246246 local task = self :peek (id )
@@ -255,15 +255,15 @@ function tube.bury(self, id)
255255end
256256
257257function tube .kick (self , count )
258- if not check_state () then
258+ if not check_state (" kick " ) then
259259 return nil
260260 end
261261 count = count or 1
262262 return self .raw :kick (count )
263263end
264264
265265function tube .delete (self , id )
266- if not check_state () then
266+ if not check_state (" delete " ) then
267267 return nil
268268 end
269269 self :peek (id )
272272
273273-- drop tube
274274function tube .drop (self )
275- if not check_state () then
275+ if not check_state (" drop " ) then
276276 return nil
277277 end
278278 local tube_name = self .name
309309-- truncate tube
310310-- (delete everything from tube)
311311function tube .truncate (self )
312- if not check_state () then
312+ if not check_state (" truncate " ) then
313313 return
314314 end
315315 self .raw :truncate ()
@@ -322,7 +322,7 @@ function tube.on_task_change(self, cb)
322322end
323323
324324function tube .grant (self , user , args )
325- if not check_state () then
325+ if not check_state (" grant " ) then
326326 return
327327 end
328328 local function tube_grant_space (user , name , tp )
583583---- ---------------------------------------------------------------------------
584584-- create tube
585585function method .create_tube (tube_name , tube_type , opts )
586- if not check_state () then
586+ if not check_state (" create_tube " ) then
587587 return
588588 end
589589 opts = opts or {}
0 commit comments