query

package
v3.3.13 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UseCase

type UseCase struct {
	// TransactionRepo provides an abstraction on top of the transaction data source.
	TransactionRepo transaction.Repository

	// OperationRepo provides an abstraction on top of the operation data source.
	OperationRepo operation.Repository

	// AssetRateRepo provides an abstraction on top of the operation data source.
	AssetRateRepo assetrate.Repository

	// BalanceRepo provides an abstraction on top of the balance data source.
	BalanceRepo balance.Repository

	// OperationRouteRepo provides an abstraction on top of the operation route data source.
	OperationRouteRepo operationroute.Repository

	// TransactionRouteRepo provides an abstraction on top of the transaction route data source.
	TransactionRouteRepo transactionroute.Repository

	// MetadataRepo provides an abstraction on top of the metadata data source.
	MetadataRepo mongodb.Repository

	// RabbitMQRepo provides an abstraction on top of the producer rabbitmq.
	RabbitMQRepo rabbitmq.ProducerRepository

	// RedisRepo provides an abstraction on top of the redis consumer.
	RedisRepo redis.RedisRepository
}

UseCase is a struct that aggregates various repositories for simplified access in use case implementations.

func (*UseCase) GetAccountAndLock

func (uc *UseCase) GetAccountAndLock(ctx context.Context, organizationID, ledgerID, transactionID uuid.UUID, parserDSL *libTransaction.Transaction, validate *libTransaction.Responses, balances []*mmodel.Balance, transactionStatus string) ([]*mmodel.Balance, error)

GetAccountAndLock func responsible to integrate core business logic to redis.

func (*UseCase) GetAllAssetRatesByAssetCode

func (uc *UseCase) GetAllAssetRatesByAssetCode(ctx context.Context, organizationID, ledgerID uuid.UUID, fromAssetCode string, filter http.QueryHeader) ([]*assetrate.AssetRate, libHTTP.CursorPagination, error)

GetAllAssetRatesByAssetCode returns all asset rates by asset codes.

func (*UseCase) GetAllBalances

func (uc *UseCase) GetAllBalances(ctx context.Context, organizationID, ledgerID uuid.UUID, filter http.QueryHeader) ([]*mmodel.Balance, libHTTP.CursorPagination, error)

func (*UseCase) GetAllBalancesByAccountID

func (uc *UseCase) GetAllBalancesByAccountID(ctx context.Context, organizationID, ledgerID, accountID uuid.UUID, filter http.QueryHeader) ([]*mmodel.Balance, libHTTP.CursorPagination, error)

func (*UseCase) GetAllBalancesByAlias

func (uc *UseCase) GetAllBalancesByAlias(ctx context.Context, organizationID, ledgerID uuid.UUID, alias string) ([]*mmodel.Balance, error)

func (*UseCase) GetAllMetadataOperationRoutes

func (uc *UseCase) GetAllMetadataOperationRoutes(ctx context.Context, organizationID, ledgerID uuid.UUID, filter http.QueryHeader) ([]*mmodel.OperationRoute, libHTTP.CursorPagination, error)

GetAllMetadataOperationRoutes fetch all Operation Routes from the repository filtered by metadata

func (*UseCase) GetAllMetadataOperations

func (uc *UseCase) GetAllMetadataOperations(ctx context.Context, organizationID, ledgerID, accountID uuid.UUID, filter http.QueryHeader) ([]*operation.Operation, libHTTP.CursorPagination, error)

GetAllMetadataOperations fetch all Operations from the repository

func (*UseCase) GetAllMetadataTransactionRoutes

func (uc *UseCase) GetAllMetadataTransactionRoutes(ctx context.Context, organizationID, ledgerID uuid.UUID, filter http.QueryHeader) ([]*mmodel.TransactionRoute, libHTTP.CursorPagination, error)

GetAllMetadataTransactionRoutes fetch all Transaction Routes from the repository filtered by metadata

func (*UseCase) GetAllMetadataTransactions

func (uc *UseCase) GetAllMetadataTransactions(ctx context.Context, organizationID, ledgerID uuid.UUID, filter http.QueryHeader) ([]*transaction.Transaction, libHTTP.CursorPagination, error)

GetAllMetadataTransactions fetch all Transactions from the repository

func (*UseCase) GetAllOperationRoutes

func (uc *UseCase) GetAllOperationRoutes(ctx context.Context, organizationID, ledgerID uuid.UUID, filter http.QueryHeader) ([]*mmodel.OperationRoute, libHTTP.CursorPagination, error)

GetAllOperationRoutes fetch all Operation Routes from the repository

func (*UseCase) GetAllOperations

func (uc *UseCase) GetAllOperations(ctx context.Context, organizationID, ledgerID, transactionID uuid.UUID, filter http.QueryHeader) ([]*operation.Operation, libHTTP.CursorPagination, error)

func (*UseCase) GetAllOperationsByAccount

func (uc *UseCase) GetAllOperationsByAccount(ctx context.Context, organizationID, ledgerID, accountID uuid.UUID, filter http.QueryHeader) ([]*operation.Operation, libHTTP.CursorPagination, error)

func (*UseCase) GetAllTransactionRoutes

func (uc *UseCase) GetAllTransactionRoutes(ctx context.Context, organizationID, ledgerID uuid.UUID, filter http.QueryHeader) ([]*mmodel.TransactionRoute, libHTTP.CursorPagination, error)

GetAllTransactionRoutes fetch all Transaction Routes from the repository

func (*UseCase) GetAllTransactions

func (uc *UseCase) GetAllTransactions(ctx context.Context, organizationID, ledgerID uuid.UUID, filter http.QueryHeader) ([]*transaction.Transaction, libHTTP.CursorPagination, error)

GetAllTransactions fetch all Transactions from the repository

func (*UseCase) GetAssetRateByExternalID

func (uc *UseCase) GetAssetRateByExternalID(ctx context.Context, organizationID, ledgerID, externalID uuid.UUID) (*assetrate.AssetRate, error)

GetAssetRateByExternalID gets data in the repository.

func (*UseCase) GetBalanceByID

func (uc *UseCase) GetBalanceByID(ctx context.Context, organizationID, ledgerID, balanceID uuid.UUID) (*mmodel.Balance, error)

GetBalanceByID gets data in the repository.

func (*UseCase) GetBalances

func (uc *UseCase) GetBalances(ctx context.Context, organizationID, ledgerID, transactionID uuid.UUID, parserDSL *libTransaction.Transaction, validate *libTransaction.Responses, transactionStatus string) ([]*mmodel.Balance, error)

GetBalances methods responsible to get balances from a database.

func (*UseCase) GetOperationByAccount

func (uc *UseCase) GetOperationByAccount(ctx context.Context, organizationID, ledgerID, accountID, operationID uuid.UUID) (*operation.Operation, error)

func (*UseCase) GetOperationByID

func (uc *UseCase) GetOperationByID(ctx context.Context, organizationID, ledgerID, transactionID, operationID uuid.UUID) (*operation.Operation, error)

GetOperationByID gets data in the repository.

func (*UseCase) GetOperationRouteByID

func (uc *UseCase) GetOperationRouteByID(ctx context.Context, organizationID, ledgerID uuid.UUID, portfolioID *uuid.UUID, id uuid.UUID) (*mmodel.OperationRoute, error)

GetOperationRouteByID retrieves an operation route by its ID. It returns the operation route if found, otherwise it returns an error.

func (*UseCase) GetOperationsByTransaction

func (uc *UseCase) GetOperationsByTransaction(ctx context.Context, organizationID, ledgerID uuid.UUID, tran *transaction.Transaction, filter http.QueryHeader) (*transaction.Transaction, error)

func (*UseCase) GetOrCreateTransactionRouteCache

func (uc *UseCase) GetOrCreateTransactionRouteCache(ctx context.Context, organizationID, ledgerID, transactionRouteID uuid.UUID) (mmodel.TransactionRouteCache, error)

GetOrCreateTransactionRouteCache retrieves a transaction route cache from Redis or database with fallback. If the transaction route cache exists in Redis, it returns the cached data as TransactionRouteCache. If not found in cache, it fetches the transaction route from database and creates the cache for future use. The cache is persistent (no TTL) and stores the msgpack-encoded binary representation of the transaction route cache structure.

func (*UseCase) GetParentByTransactionID

func (uc *UseCase) GetParentByTransactionID(ctx context.Context, organizationID, ledgerID, parentID uuid.UUID) (*transaction.Transaction, error)

GetParentByTransactionID gets data in the repository.

func (*UseCase) GetTransactionByID

func (uc *UseCase) GetTransactionByID(ctx context.Context, organizationID, ledgerID, transactionID uuid.UUID) (*transaction.Transaction, error)

GetTransactionByID gets data in the repository.

func (*UseCase) GetTransactionFromIdempotencyCache added in v3.3.11

func (uc *UseCase) GetTransactionFromIdempotencyCache(ctx context.Context, organizationID, ledgerID, transactionID uuid.UUID) (*transaction.Transaction, bool)

GetTransactionFromIdempotencyCache attempts to retrieve a transaction from the idempotency cache. It performs a two-step lookup: 1. Gets the idempotency key from the reverse mapping (transactionID -> idempotency key) 2. Gets the cached transaction JSON using the idempotency key

Returns the cached transaction and true if found, or nil and false on cache miss or any error. This method uses graceful degradation - any error results in a cache miss rather than propagating the error.

func (*UseCase) GetTransactionRouteByID

func (uc *UseCase) GetTransactionRouteByID(ctx context.Context, organizationID, ledgerID uuid.UUID, id uuid.UUID) (*mmodel.TransactionRoute, error)

GetTransactionRouteByID retrieves a transaction route by its ID. It returns the transaction route if found, otherwise it returns an error.

func (*UseCase) GetTransactionWithOperationsByID

func (uc *UseCase) GetTransactionWithOperationsByID(ctx context.Context, organizationID, ledgerID, transactionID uuid.UUID) (*transaction.Transaction, error)

GetTransactionWithOperationsByID gets data in the repository.

func (*UseCase) ValidateAccountingRules

func (uc *UseCase) ValidateAccountingRules(ctx context.Context, organizationID, ledgerID uuid.UUID, operations []mmodel.BalanceOperation, validate *libTransaction.Responses) error

ValidateAccountingRules validates the accounting rules for the given operations

func (*UseCase) ValidateIfBalanceExistsOnRedis

func (uc *UseCase) ValidateIfBalanceExistsOnRedis(ctx context.Context, organizationID, ledgerID uuid.UUID, aliases []string) ([]*mmodel.Balance, []string)

ValidateIfBalanceExistsOnRedis func that validate if balance exists on redis before to get on database.

Jump to

Keyboard shortcuts

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