ballerina/transactions package

Type Definitions

Type Values Description
TransactionState prepared | committed | active | aborted

Records Summary

Record Description
Anonymous Record 0
Anonymous Record 1
NotifyRequest
NotifyResponse
Participant2pcClientConfig
PrepareRequest
PrepareResponse
RemoteProtocol This represents the protocol associated with the coordination type.
RequestError
TransactionContext

Objects Summary

Object Description
Participant2pcClient

Endpoints Summary

Endpoint Description
Participant2pcClientEP

Functions Summary

Return Type Function and Description
string getCurrentTransactionId()

Get the current transaction id. This function is useful for user code to save state against a transaction ID, so that when the oncommit or onabort functions registered for a transaction can retrieve that state using the transaction that is passed in to those functions.

TransactionContext | error registerParticipantWithRemoteInitiator(string transactionId, int transactionBlockId, string registerAtURL, transactions:RemoteProtocol[] participantProtocols)

Registers a participant with the initiator's coordinator. This function will be called by the participant

Global Variables

Name Data Type Description
COMMAND_ABORT string
COMMAND_COMMIT string
COMMAND_PREPARE string
NOTIFY_RESULT_ABORTED_STR string
NOTIFY_RESULT_COMMITTED_STR string
NOTIFY_RESULT_FAILED_EOT_STR string
NOTIFY_RESULT_NOT_PREPARED_STR string
OUTCOME_ABORTED string
OUTCOME_COMMITTED string
PREPARE_RESULT_ABORTED_STR string
PREPARE_RESULT_COMMITTED_STR string
PREPARE_RESULT_PREPARED_STR string
PREPARE_RESULT_READ_ONLY_STR string
TRANSACTION_UNKNOWN string
TXN_STATE_ACTIVE TransactionState
TXN_STATE_PREPARED TransactionState

public type Anonymous Record 0 record

Field Name Data Type Default Value Description
count int
interval int

public type Anonymous Record 1 record

Field Name Data Type Default Value Description
count int
interval int

public type NotifyRequest record

Field Name Data Type Default Value Description
transactionId string
message string

public type NotifyResponse record

Field Name Data Type Default Value Description
message string

public type Participant2pcClientConfig record

Field Name Data Type Default Value Description
participantURL string
timeoutMillis int
retryConfig transactions:$anonType$1

public type PrepareRequest record

Field Name Data Type Default Value Description
transactionId string

public type PrepareResponse record

Field Name Data Type Default Value Description
message string

public type RemoteProtocol record

This represents the protocol associated with the coordination type.

Field Name Data Type Default Value Description
name string
  • protocol name
url string
  • protocol URL. This URL will have a value only if the participant is remote. If the participant is local, the protocolFn will be called

public type RequestError record

Field Name Data Type Default Value Description
errorMessage string

public type TransactionContext record

Field Name Data Type Default Value Description
contextVersion string 1.0
transactionId string
transactionBlockId int
coordinationType string
registerAtURL string

public function getCurrentTransactionId() returns (string)

Get the current transaction id. This function is useful for user code to save state against a transaction ID, so that when the oncommit or onabort functions registered for a transaction can retrieve that state using the transaction that is passed in to those functions.

Return Type Description
string

public function registerParticipantWithRemoteInitiator(string transactionId, int transactionBlockId, string registerAtURL, transactions:RemoteProtocol[] participantProtocols) returns (TransactionContext | error)

Registers a participant with the initiator's coordinator. This function will be called by the participant

Parameter Name Data Type Default Value Description
transactionId string
  • ID of the transaction to which this participant is registering with
transactionBlockId int
  • The local ID of the transaction block on the participant
registerAtURL string
  • The URL of the initiator to which this participant will register with
participantProtocols transactions:RemoteProtocol[]
Return Type Description
TransactionContext | error

public type Participant2pcClient object

  • <Participant2pcClient> prepare(string transactionId) returns (string | error)

    Parameter Name Data Type Default Value Description
    transactionId string
    Return Type Description
    string | error
  • <Participant2pcClient> notify(string transactionId, string message) returns (string | error)

    Parameter Name Data Type Default Value Description
    transactionId string
    message string
    Return Type Description
    string | error

Endpoint Participant2pcClientEP

  • <Participant2pcClientEP> prepare(string transactionId) returns (string|error)

    Parameter Name Data Type Default Value Description
    transactionId string
    Return Type Description
    string|error
  • <Participant2pcClientEP> notify(string transactionId, string message) returns (string|error)

    Parameter Name Data Type Default Value Description
    transactionId string
    message string
    Return Type Description
    string|error