Package gofer :: Package rmi :: Module store :: Class PendingQueue
[hide private]
[frames] | no frames]

Class PendingQueue

source code

object --+
         |
        PendingQueue

Persistent (local) storage of pending envelopes that have been processed of an AMQP queue. Most likely use is for messages with a future window which cannot be processed immediately.

Nested Classes [hide private]
  __metaclass__
Singleton metaclass usage: __metaclass__ = Singleton
Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
add(self, url, envelope)
Enqueue the specified envelope.
source code
Envelope
get(self, wait=10)
Get the next pending envelope.
source code
 
commit(self, sn)
Commit an entry returned by get().
source code
 
__purge(self, envelope)
Purge the queue entry.
source code
 
__pendingcommit(self, envelope)
Move the envelope to the uncommitted list.
source code
 
__load(self)
Load the in-memory queue from filesystem.
source code
Envelope
__import(self, path)
Import a stored envelpoe.
source code
Envelope
__get(self, wait=1)
Get the next pending envelope.
source code
Envelope
__pop(self, queue)
Pop and return the next ready entry.
source code
 
__mkdir(self)
Ensure the directory exists.
source code
int
__created(self, path)
Get create timestamp.
source code
int
__modified(self, path)
Get modification timestamp.
source code
str
__fn(self, envelope)
Get the qualified file name for an entry.
source code
bool
__expired(self, envelope)
Get whether the envelope has expired.
source code
 
__adjustTTL(self, envelope)
Adjust the TTL based on time spent on the queue.
source code
bool
__delayed(self, envelope)
Get whether the envelope has a future window.
source code
 
__copy(self, collection) source code
 
__read(self, path) source code
 
__lock(self) source code
 
__unlock(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
str ROOT = '/var/lib/gofer/messaging/pending'
The root directory used for storage.
Instance Variables [hide private]
str id
The queue id.
int lastmod
Last (directory) modification.
[Envelope,..] pending
The queue of pending envelopes.
[path,..] uncommitted
A list (removed) of files pending commit.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

add(self, url, envelope)

source code 

Enqueue the specified envelope.

Parameters:

get(self, wait=10)

source code 

Get the next pending envelope.

Parameters:
  • wait (int) - The number of seconds to block.
Returns: Envelope
An Envelope

commit(self, sn)

source code 

Commit an entry returned by get().

Parameters:
  • sn (str) - The serial number to commit.
Raises:
  • KeyError - when no found.

__purge(self, envelope)

source code 

Purge the queue entry.

Parameters:

__pendingcommit(self, envelope)

source code 

Move the envelope to the uncommitted list.

Parameters:

__import(self, path)

source code 

Import a stored envelpoe.

Parameters:
  • path (str) - An absolute file path.
Returns: Envelope
An imported envelope.

__get(self, wait=1)

source code 

Get the next pending envelope.

Parameters:
  • wait (int) - The number of seconds to wait for a pending item.
Returns: Envelope
(url, Envelope)

__pop(self, queue)

source code 

Pop and return the next ready entry. Entries that have expired (TTL), are purged. Entries that have a future window are excluded.

Parameters:
  • queue (list) - An ordered list of candidate entries.
Returns: Envelope
An Envelope

__created(self, path)

source code 

Get create timestamp.

Returns: int
The file create timestamp.

__modified(self, path)

source code 

Get modification timestamp.

Returns: int
The file modification timestamp.

__fn(self, envelope)

source code 

Get the qualified file name for an entry.

Parameters:
Returns: str
The absolute file path.

__expired(self, envelope)

source code 

Get whether the envelope has expired.

Parameters:
Returns: bool
True when expired based on TTL.

__adjustTTL(self, envelope)

source code 

Adjust the TTL based on time spent on the queue.

Parameters:

__delayed(self, envelope)

source code 

Get whether the envelope has a future window. Cancelled requests are not considered to be delayed and the window is ignored.

Parameters:
Returns: bool
True when window in the future.