pip_services3_commons.data.IdGenerator module

pip_services3_commons.data.IdGenerator

ID generator implementation.

copyright

Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.

license

MIT, see LICENSE for more details.

class pip_services3_commons.data.IdGenerator.IdGenerator

Bases: object

Helper class to generate unique object IDs. It supports two types of IDs: long and short.

Long IDs are string GUIDs. They are globally unique and 32-character long. ShortIDs are just 9-digit random numbers. They are not guaranteed be unique.

Example:

IdGenerator.next_long()      # Possible result: "234ab342c56a2b49c2ab42bf23ff991ac"
IdGenerator.next_short()     # Possible result: "23495247"
static next_long()str

Generates a globally unique 32-digit object ID. The args is a string representation of a GUID args.

Returns

a generated 32-digit object ID

static next_short()str

Generates a random 9-digit random ID (code). Remember: The returned args is not guaranteed to be unique.

Returns

a generated random 9-digit code