query

package
v3.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 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 *pkgTransaction.Transaction, validate *pkgTransaction.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)

GetAllBalances methods responsible to get all balances from a database. This method is used to get all balances from a database and return them in a cursor pagination format. It also validates if the balance is currently in the redis cache and if so, it uses the cached values instead of the database values.

func (*UseCase) GetAllBalancesByAccountID

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

GetAllBalancesByAccountID methods responsible to get all balances by account id from a database. This method is used to get all balances by account id from a database and return them in a cursor pagination format. It also validates if the balance is currently in the redis cache and if so, it uses the cached values instead of the database values.

func (*UseCase) GetAllBalancesByAlias

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

GetAllBalancesByAlias methods responsible to get all balances from a database by alias. This method is used to get all balances from a database by alias and return them in a slice. It also validates if the balance is currently in the redis cache and if so, it uses the cached values instead of the database values.

func (*UseCase) GetAllMetadataIndexes added in v3.5.0

func (uc *UseCase) GetAllMetadataIndexes(ctx context.Context, filter http.QueryHeader) ([]*mmodel.MetadataIndex, error)

GetAllMetadataIndexes returns all metadata indexes, optionally filtered by entity name

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 *pkgTransaction.Transaction, validate *pkgTransaction.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) 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) GetWriteBehindTransaction added in v3.3.15

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

GetWriteBehindTransaction retrieves a transaction from the write-behind cache in Redis. Returns the deserialized transaction with Body and Operations already populated. Returns (nil, err) on cache miss or deserialization failure.

func (*UseCase) ValidateAccountingRules

func (uc *UseCase) ValidateAccountingRules(ctx context.Context, organizationID, ledgerID uuid.UUID, operations []mmodel.BalanceOperation, validate *pkgTransaction.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