ballerina/transactions module

Module Detail

Records

Record Description
NotifyRequest
NotifyResponse
Participant2pcClientConfig
PrepareRequest
PrepareResponse
RemoteProtocol This represents the protocol associated with the coordination type.
RequestError
TransactionContext
TransactionParticipantConfig Contains the configurations for local transaction participant function.

Endpoints

Endpoint Description
Participant2pcClientEP

Functions

Function Description
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.

registerParticipantWithRemoteInitiator

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

Type Definitions

Type Values Description
UProtocol RemoteProtocol | LocalProtocol

Annotations

Name Attaches To Data Type Description
Participant resource, function TransactionParticipantConfig

The annotation which is used to configure local transaction participant function.

public type NotifyRequest

Field Name Data Type Default Value Description
transactionId string
message string

public type NotifyResponse

Field Name Data Type Default Value Description
message string

public type Participant2pcClientConfig

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

public type PrepareRequest

Field Name Data Type Default Value Description
transactionId string

public type PrepareResponse

Field Name Data Type Default Value Description
message string

public type 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 type RequestError

Field Name Data Type Default Value Description
errorMessage string

public type TransactionContext

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

public type TransactionParticipantConfig

Contains the configurations for local transaction participant function.

Field Name Data Type Default Value Description
oncommit function (string) returns ()

Function to execute when transaction committed.

onabort function (string) returns ()

Function to execute when transaction aborted.

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

A string representing the ID of the current transaction.

public function registerParticipantWithRemoteInitiator(string transactionId, string 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

Global transaction ID to which this participant is registering with.

transactionBlockId string

The local ID of the transaction block on the participant.

registerAtURL string

The URL of the coordinator.

participantProtocols transactions:RemoteProtocol[]

The coordination protocals supported by the participant.

Return Type Description
TransactionContext|error<>

TransactionContext if the registration is successful or an error in case of a failure.

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