gc3libs.persistence.idfactory

class gc3libs.persistence.idfactory.Id

An automatically-generated “unique identifier” (a string-like object). The unique object identifier has the form “PREFIX.NNN” where “NNN” is a decimal number, and “PREFIX” defaults to the object class name but can be overridden in the Id constructor.

Two object IDs can be compared iff they have the same prefix; in which case, the result of the comparison is the same as comparing the two sequence numbers.

class gc3libs.persistence.idfactory.IdFactory(prefix=None, next_id_fn=None, id_class=<class 'gc3libs.persistence.idfactory.Id'>)

Automatically generate a “unique identifier” (of class Id). Object identifiers are temporally unique: no identifier will (ever) be re-used, even in different invocations of the program.

new(obj)

Return a new “unique identifier” instance (a string).

reserve(n)

Pre-allocate n IDs. Successive invocations of the Id constructor will return one of the pre-allocated, with a potential speed gain if many Id objects are constructed in a loop.

class gc3libs.persistence.idfactory.JobIdFactory(next_id_fn=None)

Override IdFactory behavior and generate IDs starting with a lowercase job prefix.