Reference Source
public class | source

Transaction

Extends:

devapt-core-common/dist/js/base/instance~Instance → Transaction

Constructor Summary

Public Constructor
public

constructor(arg_app_name: string, arg_svc_name: string, arg_tx_name: string, arg_settings: object, arg_executables: Array, arg_type: string): nothing

Create a Transaction.

Member Summary

Public Members
public

executables: array

Executables array.

public

Class test flag.

public

Duration metric instance.

public

Metrics array.

public

results: array

Results array.

public

Transaction status.

public

Transaction type.

Method Summary

Public Methods
public

commit(): nothing

Commit transaction execution on executables success.

public

execute(arg_data: anything): Promise

Execute all executables regarding the transaction type.

public

execute_every(arg_data: anything): Promise

Execute every executables without order and fails if one failure appears.

public

execute_one(arg_data: anything): Promise

Execute every executables without order and fulfill on first resolved, fails if one failure appears.

public

execute_sequence(arg_data: anything): Promise

Execute every executables in a fixed order and stop on failure.

public

finish(): nothing

Finish all executables.

public

Get instance description: {$type:..., $class:..., $id:..., $name:...}.

public

Get result of the first ended executable which failed.

public

Get result of the first ended executable.

public

Get transaction metrics: {id:..., status:..., metrics:...}.

public

Get executables results array: {index:..., result:..., has_error:..., error_msg:...}.

public

prepare(arg_context: object): nothing

Prepare transaction executables.

public

rollback(): nothing

Rollback transaction execution on executables failure.

public

set_executables(arg_executables: Array): nothing

Set transaction executables.

public

set_type(arg_type: string): nothing

Set the transaction type.

Public Constructors

public constructor(arg_app_name: string, arg_svc_name: string, arg_tx_name: string, arg_settings: object, arg_executables: Array, arg_type: string): nothing source

Create a Transaction. Set status to CREATED.

Params:

NameTypeAttributeDescription
arg_app_name string

application name.

arg_svc_name string

service name.

arg_tx_name string

transaction name.

arg_settings object

settings

arg_executables Array

executables array (optional)

arg_type string

transaction type (optional)

Return:

nothing

Public Members

public executables: array source

Executables array.

public is_transaction: boolean source

Class test flag.

public metric_duration: MetricDuration source

Duration metric instance.

public metrics: Array source

Metrics array.

public results: array source

Results array.

public status: string source

Transaction status.

public tx_type: string source

Transaction type.

Public Methods

public commit(): nothing source

Commit transaction execution on executables success. Change status to EXEC_OK.

Return:

nothing

public execute(arg_data: anything): Promise source

Execute all executables regarding the transaction type.

Params:

NameTypeAttributeDescription
arg_data anything

any parameter

Return:

Promise

a promise of executables results array

public execute_every(arg_data: anything): Promise source

Execute every executables without order and fails if one failure appears.

Params:

NameTypeAttributeDescription
arg_data anything

any parameter

Return:

Promise

a promise of executables results array

public execute_one(arg_data: anything): Promise source

Execute every executables without order and fulfill on first resolved, fails if one failure appears.

Params:

NameTypeAttributeDescription
arg_data anything

any parameter

Return:

Promise

a promise of executables results array

public execute_sequence(arg_data: anything): Promise source

Execute every executables in a fixed order and stop on failure.

Params:

NameTypeAttributeDescription
arg_data anything

any parameter

Return:

Promise

a promise of executables results array

public finish(): nothing source

Finish all executables.

Return:

nothing

public get_descriptor(): object source

Get instance description: {$type:..., $class:..., $id:..., $name:...}.

Return:

object

instance object description

public get_first_error(): object source

Get result of the first ended executable which failed.

Return:

object

error object.

public get_first_result(): object source

Get result of the first ended executable.

Return:

object

result object.

public get_metrics(): object source

Get transaction metrics: {id:..., status:..., metrics:...}.

Return:

object

transaction metrics plain object

public get_results(): Array source

Get executables results array: {index:..., result:..., has_error:..., error_msg:...}.

Return:

Array

all executed executables results.

public prepare(arg_context: object): nothing source

Prepare transaction executables. Change status to PREPARED.

Params:

NameTypeAttributeDescription
arg_context object

executables context.

Return:

nothing

public rollback(): nothing source

Rollback transaction execution on executables failure. Change status to EXEC_KO.

Return:

nothing

public set_executables(arg_executables: Array): nothing source

Set transaction executables.

Params:

NameTypeAttributeDescription
arg_executables Array

executables instances array.

Return:

nothing

public set_type(arg_type: string): nothing source

Set the transaction type. Value should be choosen from the list:EVERY,SEQUENCE,ONE

  • EVERY: transaction is finished when all executables are finished without order.
  • SEQUENCE: transaction is finished when all executables are finished in a ordered sequence.
  • ONE: transaction is finished when an executable finished without waiting other executables.

Params:

NameTypeAttributeDescription
arg_type string

transaction type value.

Return:

nothing