# Module cloudi_trans_id

- Description
- Function Index
- Function Details

### CloudI Transaction ID Usage

Convenience functions for using the v1 UUID used as the transaction id ("TransId" or "trans_id") that follows a CloudI service request for the lifetime (defined by the service request timeout) of the request and its response result.

Copyright © 2015-2020 Michael Truog

Version: 2.0.1 Dec 3 2021 17:15:35 ------------------------------------------------------------------------

Authors: Michael Truog (`mjtruog at protonmail dot com`).

## Description

### CloudI Transaction ID Usage

Convenience functions for using the v1 UUID used as the transaction id ("TransId" or "trans_id") that follows a CloudI service request for the lifetime (defined by the service request timeout) of the request and its response result.

## Function Index

datetime/1 | #### Provide an ISO8601 datetime in UTC based on the time stored in the transaction id. .
datetime/2 | #### Provide an ISO8601 datetime in UTC based on the time stored in the transaction id with an offset in microseconds. .
from_string/1 | #### Return a transaction id as a binary UUID (16 bytes). .
increment/1 | #### Increment the transaction id while preserving uniqueness. Increment the v1 UUID's clock_seq (14bit) integer for 16384 possible v1 UUID values based on a single transaction id.
microseconds/0 | #### Microseconds since the UNIX epoch. The integer value returned uses the same time source used for creating TransId v1 UUIDs, though the return values are not strictly monotonically increasing on Erlang >= 18.0 if the OS time is changed (TransId v1 UUID time values are strictly monotonically increasing when comparing TransId values created by the same service Erlang process).
microseconds/1 | #### Microseconds since the UNIX epoch. The integer value returned is always increasing for each service process that created the TransId (with the service process uniquely represented in the node_id section of the v1 UUID).
to_string/1 | #### Return the transaction id in a standard string format. .
to_string/2 | #### Return the transaction id in a string format. .

## Function Details

### datetime/1

`datetime(TransId::uuid:uuid()) -> cloudi_timestamp:iso8601()`

#### Provide an ISO8601 datetime in UTC based on the time stored in the transaction id.

### datetime/2

`datetime(TransId::uuid:uuid(), MicroSecondsOffset::integer()) -> cloudi_timestamp:iso8601()`

#### Provide an ISO8601 datetime in UTC based on the time stored in the transaction id with an offset in microseconds.

### from_string/1

`from_string(String::uuid:uuid_string()) -> uuid:uuid()`

#### Return a transaction id as a binary UUID (16 bytes).

### increment/1

`increment(TransId::uuid:uuid()) -> uuid:uuid()`

#### Increment the transaction id while preserving uniqueness.

Increment the v1 UUID's clock_seq (14bit) integer for 16384 possible v1 UUID values based on a single transaction id.

### microseconds/0

`microseconds() -> non_neg_integer()`

#### Microseconds since the UNIX epoch.

The integer value returned uses the same time source used for creating TransId v1 UUIDs, though the return values are not strictly monotonically increasing on Erlang >= 18.0 if the OS time is changed (TransId v1 UUID time values are strictly monotonically increasing when comparing TransId values created by the same service Erlang process). (The UNIX epoch is 1970-01-01T00:00:00)

### microseconds/1

`microseconds(TransId::uuid:uuid()) -> non_neg_integer()`

#### Microseconds since the UNIX epoch.

The integer value returned is always increasing for each service process that created the TransId (with the service process uniquely represented in the node_id section of the v1 UUID). (The UNIX epoch is 1970-01-01T00:00:00)

### to_string/1

`to_string(TransId::uuid:uuid()) -> uuid:uuid_string_list()`

#### Return the transaction id in a standard string format.

### to_string/2

`to_string(TransId::uuid:uuid(), Format::standard | nodash | list_standard | list_nodash | binary_standard | binary_nodash) -> uuid:uuid_string()`

#### Return the transaction id in a string format.

Generated by EDoc