workflows

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestGetMethods    func(ctx context.Context, client *client.Client, orgID, ledgerID, accountID string, portfolioID string) error
	TestListMethods   func(ctx context.Context, client *client.Client, orgID, ledgerID string) error
	TestDeleteMethods func(ctx context.Context, client *client.Client, orgID, ledgerID string) error
)

Function declarations to satisfy the compiler These are placeholder functions that will be implemented in separate files

Functions

func CreateAccounts

func CreateAccounts(ctx context.Context, client *client.Client, orgID, ledgerID string) (*models.Account, *models.Account, *models.Account, *models.Account, error)

CreateAccounts creates customer and merchant accounts and returns their models

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger

Returns:

  • *models.Account: The customer account model
  • *models.Account: The merchant account model
  • *models.Account: The dummy 1 account model
  • *models.Account: The dummy 2 account model
  • error: Any error encountered during the operation

func CreateAsset

func CreateAsset(ctx context.Context, client *client.Client, orgID, ledgerID string) error

CreateAsset creates a new USD asset

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger

Returns:

  • error: Any error encountered during the operation

func CreateDepositInput

func CreateDepositInput(description string, amount int64, sourceAccountID, destinationAccountID string) *models.CreateTransactionInput

CreateDepositInput is a helper function to create a deposit transaction input

Parameters:

  • description: The description of the transaction
  • amount: The amount of the transaction (in cents)
  • sourceAccountID: The ID of the account to deposit from
  • destinationAccountID: The ID of the account to deposit to

Returns:

  • *models.CreateTransactionInput: The deposit transaction input

func CreateLedger

func CreateLedger(ctx context.Context, client *client.Client, orgID string) (string, error)

CreateLedger creates a ledger in the organization

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • cfg: The configuration object
  • client: The initialized Midaz SDK client
  • orgID: The ID of the organization

Returns:

  • string: The ID of the created ledger
  • error: Any error encountered during the operation

func CreateOrganization

func CreateOrganization(ctx context.Context, client *client.Client) (string, error)

CreateOrganization creates a new organization and returns its ID

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • client: The initialized Midaz SDK client

Returns:

  • string: The ID of the created organization
  • error: Any error encountered during the operation

func CreatePortfolio

func CreatePortfolio(ctx context.Context, client *client.Client, orgID, ledgerID string) (string, error)

CreatePortfolio creates a portfolio

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger

Returns:

  • string: The ID of the created portfolio
  • error: Any error encountered during the operation

func CreateSegments

func CreateSegments(ctx context.Context, client *client.Client, orgID, ledgerID string) error

CreateSegments creates segments within a ledger

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger

Returns:

  • error: Any error encountered during the operation

func CreateTransferInput

func CreateTransferInput(description string, amount int64, fromAccountID, toAccountID string, index int) *models.CreateTransactionInput

CreateTransferInput is a helper function to create a transfer transaction input

Parameters:

  • description: The description of the transaction
  • amount: The amount of the transaction (in cents)
  • fromAccountID: The ID of the account to transfer from
  • toAccountID: The ID of the account to transfer to
  • index: The index of the transaction (for logging purposes)

Returns:

  • *models.CreateTransactionInput: The transfer transaction input

func DemonstrateTransactionHelpers

func DemonstrateTransactionHelpers(ctx context.Context, client *client.Client, orgID, ledgerID string, customerAccount, merchantAccount, dummyOneAccount, dummyTwoAccount *models.Account) error

DemonstrateTransactionHelpers showcases the transaction helpers in the SDK

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger
  • customerAccount: The customer account model
  • merchantAccount: The merchant account model
  • dummyOneAccount: The dummy 1 account model
  • dummyTwoAccount: The dummy 2 account model

Returns:

  • error: Any error encountered during the operation

func ExecuteConcurrentTransactions

func ExecuteConcurrentTransactions(ctx context.Context, client *client.Client, orgID, ledgerID string, customerAccount, merchantAccount *midazmodels.Account) error

ExecuteConcurrentTransactions performs concurrent transactions between accounts to test TPS

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger
  • customerAccount: The customer account model
  • merchantAccount: The merchant account model

Returns:

  • error: Any error encountered during the operation

func ExecuteCustomerToMerchantConcurrent

func ExecuteCustomerToMerchantConcurrent(ctx context.Context, client *client.Client, orgID, ledgerID string, customerAccount, merchantAccount *midazmodels.Account, count int) error

ExecuteCustomerToMerchantConcurrent executes concurrent transactions from customer to merchant using the SDK's concurrency helpers

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger
  • customerAccount: The customer account model
  • merchantAccount: The merchant account model
  • count: The number of concurrent transactions to execute

Returns:

  • error: Any error encountered during the operation

func ExecuteInitialDeposit

func ExecuteInitialDeposit(ctx context.Context, client *client.Client, orgID, ledgerID string, customerAccount *models.Account, externalAccountID string) error

ExecuteInitialDeposit performs the initial deposit from external account to customer account

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger
  • customerAccount: The customer account model
  • externalAccountID: The external account ID

Returns:

  • error: Any error encountered during the operation

func ExecuteInsufficientFundsTransactions

func ExecuteInsufficientFundsTransactions(ctx context.Context, client *client.Client, orgID, ledgerID string, customerAccount, merchantAccount *models.Account, externalAccountID string)

ExecuteInsufficientFundsTransactions attempts transactions that should fail due to insufficient funds

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger
  • customerAccount: The customer account model
  • merchantAccount: The merchant account model
  • externalAccountID: The external account ID

func ExecuteMerchantToCustomerConcurrent

func ExecuteMerchantToCustomerConcurrent(ctx context.Context, client *client.Client, orgID, ledgerID string, customerAccount, merchantAccount *midazmodels.Account, count int) error

ExecuteMerchantToCustomerConcurrent executes concurrent transactions from merchant to customer using the SDK's concurrency helpers

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger
  • customerAccount: The customer account model
  • merchantAccount: The merchant account model
  • count: The number of concurrent transactions to execute

Returns:

  • error: Any error encountered during the operation

func ExecuteMultipleDeposits

func ExecuteMultipleDeposits(ctx context.Context, client *client.Client, orgID, ledgerID string, customerAccount, merchantAccount *models.Account, externalAccountID string) error

ExecuteMultipleDeposits performs multiple deposits to customer and merchant accounts

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger
  • customerAccount: The customer account model
  • merchantAccount: The merchant account model
  • externalAccountID: The external account ID

Returns:

  • error: Any error encountered during the operation

func ExecuteMultipleTransfers

func ExecuteMultipleTransfers(ctx context.Context, client *client.Client, orgID, ledgerID string, customerAccount, merchantAccount *models.Account) error

ExecuteMultipleTransfers performs multiple transfers between customer and merchant accounts

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger
  • customerAccount: The customer account model
  • merchantAccount: The merchant account model

Returns:

  • error: Any error encountered during the operation

func ExecuteSingleTransfer

func ExecuteSingleTransfer(ctx context.Context, client *client.Client, orgID, ledgerID string, customerAccount, merchantAccount *models.Account) error

ExecuteSingleTransfer performs a single transfer from customer to merchant

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger
  • customerAccount: The customer account model
  • merchantAccount: The merchant account model

Returns:

  • error: Any error encountered during the operation

func ExecuteTransactions

func ExecuteTransactions(ctx context.Context, client *client.Client, orgID, ledgerID string, customerAccount, merchantAccount *models.Account) error

ExecuteTransactions executes various transactions between accounts

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger
  • customerAccount: The customer account model
  • merchantAccount: The merchant account model

Returns:

  • error: Any error encountered during the operation

func ExecuteWithdrawals

func ExecuteWithdrawals(ctx context.Context, client *client.Client, orgID, ledgerID string, customerAccount, merchantAccount *models.Account, externalAccountID string) error

ExecuteWithdrawals performs withdrawals from accounts to external account

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger
  • customerAccount: The customer account model
  • merchantAccount: The merchant account model
  • externalAccountID: The external account ID

Returns:

  • error: Any error encountered during the operation

func GenerateUniqueIdempotencyKey

func GenerateUniqueIdempotencyKey(prefix string, index int) string

GenerateUniqueIdempotencyKey generates a truly unique idempotency key by combining multiple sources of uniqueness

Parameters:

  • prefix: A prefix to identify the source of the key (e.g., "c2m" for customer to merchant)
  • index: An index to identify the specific transaction

Returns:

  • string: A unique idempotency key

func ListAccounts

func ListAccounts(ctx context.Context, client *client.Client, orgID, ledgerID string) error

ListAccounts lists all accounts in the ledger

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • cfg: The configuration object
  • client: The initialized Midaz SDK client
  • orgID: The ID of the organization
  • ledgerID: The ID of the ledger

Returns:

  • error: Any error encountered during the operation

func RetrieveOrganization

func RetrieveOrganization(ctx context.Context, client *client.Client, orgID string) error

RetrieveOrganization retrieves the organization by ID

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization

Returns:

  • error: Any error encountered during the operation

func RunCompleteWorkflow

func RunCompleteWorkflow(ctx context.Context, entity *sdkentities.Entity, customerToMerchantTxs, merchantToCustomerTxs int) error

RunCompleteWorkflow runs a complete workflow demonstrating all the features of the Midaz SDK

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • customerToMerchantTxs: Number of customer to merchant transactions to execute
  • merchantToCustomerTxs: Number of merchant to customer transactions to execute

Returns:

  • error: Any error encountered during the operation

func UpdateOrganization

func UpdateOrganization(ctx context.Context, client *client.Client, orgID string) error

UpdateOrganization updates the organization metadata

Parameters:

  • ctx: The context for the operation, which can be used for cancellation
  • entity: The initialized Midaz SDK entity client
  • orgID: The ID of the organization

Returns:

  • error: Any error encountered during the operation

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL