ballerina/transactions package

Primitives Summary

Type Description

Type Definitions

Type Values Description
TransactionState prepared | committed | active | aborted

Annotations

Name Attachement Points Data Type Description

Objects Summary

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

Endpoints Summary

Endpoint Description

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, 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 object $anonRecord$0

Field Name Data Type Default Value Description
count int
interval int

public object $anonRecord$1

Field Name Data Type Default Value Description
count int
interval int

public object NotifyRequest

Field Name Data Type Default Value Description
transactionId string
message string

public object NotifyResponse

Field Name Data Type Default Value Description
message string

public object Participant2pcClientConfig

Field Name Data Type Default Value Description
participantURL string
timeoutMillis int
retryConfig $anonRecord$1

public object PrepareRequest

Field Name Data Type Default Value Description
transactionId string

public object PrepareResponse

Field Name Data Type Default Value Description
message string

public object RemoteProtocol

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 object RequestError

Field Name Data Type Default Value Description
errorMessage string

public object TransactionContext

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, 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 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

public type Participant2pcClientEP object

  • <Participant2pcClientEP> init(Participant2pcClientConfig conf)

    Parameter Name Data Type Default Value Description
    conf Participant2pcClientConfig
  • <Participant2pcClientEP> getCallerActions() returns (Participant2pcClient)

    Return Type Description
    Participant2pcClient