ballerina/transactions module
Type Definitions
Type | Values | Description | |
---|---|---|---|
UProtocol | RemoteProtocol | LocalProtocol |
Annotations
Name | Attachement Points | Data Type | Description |
---|---|---|---|
Participant | resource, function | TransactionParticipantConfig | The annotation which is used to configure local transaction participant function. |
Records Summary
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 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 |
||
TransactionContext|error<> | registerParticipantWithRemoteInitiator(string transactionId, string transactionBlockId, string registerAtURL, transactions:RemoteProtocol[] participantProtocols) Registers a participant with the initiator's coordinator. This function will be called by the participant. |
Constants
Name | Data Type | Value | Description | |
---|---|---|---|---|
COMMAND_PREPARE | string | prepare | ||
COMMAND_COMMIT | string | commit | ||
COMMAND_ABORT | string | abort | ||
PREPARE_RESULT_PREPARED_STR | string | prepared | ||
PREPARE_RESULT_ABORTED_STR | string | aborted | ||
PREPARE_RESULT_COMMITTED_STR | string | committed | ||
PREPARE_RESULT_READ_ONLY_STR | string | read-only | ||
NOTIFY_RESULT_NOT_PREPARED_STR | string | not-prepared | ||
NOTIFY_RESULT_FAILED_EOT_STR | string | failed-eot | ||
NOTIFY_RESULT_COMMITTED_STR | string | committed | ||
NOTIFY_RESULT_ABORTED_STR | string | aborted | ||
OUTCOME_COMMITTED | string | committed | ||
OUTCOME_ABORTED | string | aborted | ||
TRANSACTION_UNKNOWN | string | Transaction-Unknown |
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 | 0 | |
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 |
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 | string | ||
coordinationType | string | ||
registerAtURL | string |
public type TransactionParticipantConfig record
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<>