Documentation ¶
Overview ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func NewBalanceTracker() *model.BalanceTracker
- func ProcessWebhook(_ context.Context, task *asynq.Task) error
- func SendWebhook(newWebhook NewWebhook) error
- type BatchJobResult
- type Blnk
- func (l *Blnk) CommitInflightTransaction(ctx context.Context, transactionID string, amount float64) (*model.Transaction, error)
- func (l *Blnk) CommitWorker(ctx context.Context, jobs <-chan *model.Transaction, ...)
- func (l *Blnk) CreateAccount(account model.Account) (model.Account, error)
- func (l *Blnk) CreateBalance(ctx context.Context, balance model.Balance) (model.Balance, error)
- func (l *Blnk) CreateIdentity(identity model.Identity) (model.Identity, error)
- func (l *Blnk) CreateLedger(ledger model.Ledger) (model.Ledger, error)
- func (s *Blnk) CreateMatchingRule(ctx context.Context, rule model.MatchingRule) (*model.MatchingRule, error)
- func (l *Blnk) CreateMonitor(ctx context.Context, monitor model.BalanceMonitor) (model.BalanceMonitor, error)
- func (l *Blnk) DeleteIdentity(id string) error
- func (s *Blnk) DeleteMatchingRule(ctx context.Context, id string) error
- func (l *Blnk) DeleteMonitor(ctx context.Context, id string) error
- func (l *Blnk) GetAccount(id string, include []string) (*model.Account, error)
- func (l *Blnk) GetAccountByNumber(id string) (*model.Account, error)
- func (l *Blnk) GetAllAccounts() ([]model.Account, error)
- func (l *Blnk) GetAllBalances(ctx context.Context, limit, offset int) ([]model.Balance, error)
- func (l *Blnk) GetAllIdentities() ([]model.Identity, error)
- func (l *Blnk) GetAllLedgers(limit, offset int) ([]model.Ledger, error)
- func (l *Blnk) GetAllMonitors(ctx context.Context) ([]model.BalanceMonitor, error)
- func (l *Blnk) GetAllTransactions(limit, offset int) ([]model.Transaction, error)
- func (l *Blnk) GetBalanceByID(ctx context.Context, id string, include []string) (*model.Balance, error)
- func (l *Blnk) GetBalanceMonitors(ctx context.Context, balanceID string) ([]model.BalanceMonitor, error)
- func (l *Blnk) GetIdentity(id string) (*model.Identity, error)
- func (l *Blnk) GetInflightTransactionsByParentID(ctx context.Context, parentTransactionID string, batchSize int, offset int64) ([]*model.Transaction, error)
- func (l *Blnk) GetLedgerByID(id string) (*model.Ledger, error)
- func (s *Blnk) GetMatchingRule(ctx context.Context, id string) (*model.MatchingRule, error)
- func (l *Blnk) GetMonitorByID(ctx context.Context, id string) (*model.BalanceMonitor, error)
- func (l *Blnk) GetRefundableTransactionsByParentID(ctx context.Context, parentTransactionID string, batchSize int, offset int64) ([]*model.Transaction, error)
- func (l *Blnk) GetTransaction(ctx context.Context, TransactionID string) (*model.Transaction, error)
- func (l *Blnk) GetTransactionByRef(ctx context.Context, reference string) (model.Transaction, error)
- func (s *Blnk) ListMatchingRules(ctx context.Context) ([]*model.MatchingRule, error)
- func (l *Blnk) ProcessTransactionInBatches(ctx context.Context, parentTransactionID string, amount float64, ...) ([]*model.Transaction, error)
- func (l *Blnk) QueueTransaction(ctx context.Context, transaction *model.Transaction) (*model.Transaction, error)
- func (l *Blnk) RecordTransaction(ctx context.Context, transaction *model.Transaction) (*model.Transaction, error)
- func (l *Blnk) RefundTransaction(ctx context.Context, transactionID string) (*model.Transaction, error)
- func (l *Blnk) RefundWorker(ctx context.Context, jobs <-chan *model.Transaction, ...)
- func (l *Blnk) RejectTransaction(ctx context.Context, transaction *model.Transaction, reason string) (*model.Transaction, error)
- func (l *Blnk) Search(collection string, query *api.SearchCollectionParams) (interface{}, error)
- func (s *Blnk) StartReconciliation(ctx context.Context, uploadID string, strategy string, groupCriteria string, ...) (string, error)
- func (l *Blnk) UpdateIdentity(identity *model.Identity) error
- func (s *Blnk) UpdateMatchingRule(ctx context.Context, rule model.MatchingRule) (*model.MatchingRule, error)
- func (l *Blnk) UpdateMonitor(ctx context.Context, monitor *model.BalanceMonitor) error
- func (l *Blnk) UpdateTransactionStatus(ctx context.Context, id string, status string) error
- func (s *Blnk) UploadExternalData(ctx context.Context, source string, reader io.Reader, filename string) (string, int, error)
- func (l *Blnk) VoidInflightTransaction(ctx context.Context, transactionID string) (*model.Transaction, error)
- func (l *Blnk) VoidWorker(ctx context.Context, jobs <-chan *model.Transaction, ...)
- type MockBlnk
- type NewWebhook
- type NotificationPayload
- type Queue
- type TransactionTypePayload
- type TypesenseClient
- func (t *TypesenseClient) CreateCollection(ctx context.Context, schema *api.CollectionSchema) (*api.CollectionResponse, error)
- func (t *TypesenseClient) EnsureCollectionsExist(ctx context.Context) error
- func (t *TypesenseClient) HandleNotification(table string, data map[string]interface{}) error
- func (t *TypesenseClient) MigrateTypeSenseSchema(ctx context.Context, collectionName string) error
- func (t *TypesenseClient) Search(ctx context.Context, collection string, ...) (*api.SearchResult, error)
Constants ¶
const ( TRANSACTION_QUEUE = "new:transaction" WEBHOOK_QUEUE = "new:webhoook" INDEX_QUEUE = "new:index" EXPIREDINFLIGHT_QUEUE = "new:inflight-expiry" NumberOfQueues = 20 )
const ( StatusStarted = "started" // Indicates the process has started. StatusInProgress = "in_progress" // Indicates the process is ongoing. StatusCompleted = "completed" // Indicates the process is finished successfully. StatusFailed = "failed" // Indicates the process has failed. )
Status constants representing the various states a process can be in.
const ( StatusQueued = "QUEUED" StatusApplied = "APPLIED" StatusScheduled = "SCHEDULED" StatusInflight = "INFLIGHT" StatusVoid = "VOID" StatusCommit = "COMMIT" StatusRejected = "REJECTED" )
const (
GeneralLedgerID = "general_ledger_id"
)
Variables ¶
var SQLFiles embed.FS
Functions ¶
func NewBalanceTracker ¶
func NewBalanceTracker() *model.BalanceTracker
NewBalanceTracker creates a new BalanceTracker instance. It initializes the Balances and Frequencies maps.
Returns: - *model.BalanceTracker: A pointer to the newly created BalanceTracker instance.
func ProcessWebhook ¶
ProcessWebhook processes a webhook notification task from the queue.
Parameters: - _ context.Context: The context for the operation. - task *asynq.Task: The task containing the webhook notification data.
Returns: - error: An error if the webhook processing fails.
func SendWebhook ¶
func SendWebhook(newWebhook NewWebhook) error
SendWebhook enqueues a webhook notification task.
Parameters: - newWebhook NewWebhook: The webhook notification data to enqueue.
Returns: - error: An error if the task could not be enqueued.
Types ¶
type BatchJobResult ¶ added in v0.7.0
type BatchJobResult struct { Txn *model.Transaction Error error }
BatchJobResult represents the result of processing a transaction in a batch job.
Fields: - Txn *model.Transaction: A pointer to the processed Transaction model. - Error error: An error if the transaction could not be processed.
type Blnk ¶
type Blnk struct {
// contains filtered or unexported fields
}
Blnk represents the main struct for the Blnk application.
func NewBlnk ¶
func NewBlnk(db database.IDataSource) (*Blnk, error)
NewBlnk initializes a new instance of Blnk with the provided database datasource. It fetches the configuration, initializes Redis client, balance tracker, queue, and search client.
Parameters: - db database.IDataSource: The datasource for database operations.
Returns: - *Blnk: A pointer to the newly created Blnk instance. - error: An error if any of the initialization steps fail.
func (*Blnk) CommitInflightTransaction ¶ added in v0.6.0
func (l *Blnk) CommitInflightTransaction(ctx context.Context, transactionID string, amount float64) (*model.Transaction, error)
CommitInflightTransaction commits an inflight transaction by validating and updating its amount, and finalizing the commitment. It starts a tracing span, fetches and validates the inflight transaction, updates the amount, and finalizes the commitment.
Parameters: - ctx context.Context: The context for the operation. - transactionID string: The ID of the inflight transaction to be committed. - amount float64: The amount to be validated and updated in the transaction.
Returns: - *model.Transaction: A pointer to the committed Transaction model. - error: An error if the transaction could not be committed.
func (*Blnk) CommitWorker ¶ added in v0.7.0
func (l *Blnk) CommitWorker(ctx context.Context, jobs <-chan *model.Transaction, results chan<- BatchJobResult, wg *sync.WaitGroup, amount float64)
CommitWorker processes commit transactions from the jobs channel and sends the results to the results channel. It starts a tracing span, processes each transaction, and records relevant events and errors.
Parameters: - ctx context.Context: The context for the operation. - jobs <-chan *model.Transaction: A channel from which transactions are received for processing. - results chan<- BatchJobResult: A channel to which the results of the processing are sent. - wg *sync.WaitGroup: A wait group to synchronize the completion of the worker. - amount float64: The amount to be processed in the transaction.
func (*Blnk) CreateAccount ¶
CreateAccount creates a new account in the database. It overrides the ledger and identity details, applies the account name, and fetches external account details.
Parameters: - account model.Account: The Account model to be created.
Returns: - model.Account: The created Account model. - error: An error if the account could not be created.
func (*Blnk) CreateBalance ¶
CreateBalance creates a new balance. It starts a tracing span, creates the balance, and performs post-creation actions.
Parameters: - ctx context.Context: The context for the operation. - balance model.Balance: The Balance model to be created.
Returns: - model.Balance: The created Balance model. - error: An error if the balance could not be created.
func (*Blnk) CreateIdentity ¶
CreateIdentity creates a new identity in the database.
Parameters: - identity model.Identity: The Identity model to be created.
Returns: - model.Identity: The created Identity model. - error: An error if the identity could not be created.
func (*Blnk) CreateLedger ¶
CreateLedger creates a new ledger. It calls postLedgerActions after a successful creation.
Parameters: - ledger: A Ledger model representing the ledger to be created.
Returns: - model.Ledger: The created Ledger model. - error: An error if the ledger could not be created.
func (*Blnk) CreateMatchingRule ¶ added in v0.7.0
func (s *Blnk) CreateMatchingRule(ctx context.Context, rule model.MatchingRule) (*model.MatchingRule, error)
CreateMatchingRule creates a new matching rule after validating it. Parameters: - ctx: The context for managing the request. - rule: The matching rule to be created. Returns the created rule, or an error if validation or storage fails.
func (*Blnk) CreateMonitor ¶
func (l *Blnk) CreateMonitor(ctx context.Context, monitor model.BalanceMonitor) (model.BalanceMonitor, error)
CreateMonitor creates a new balance monitor. It starts a tracing span, applies precision to the monitor's condition value, and creates the monitor. It records relevant events and errors.
Parameters: - ctx context.Context: The context for the operation. - monitor model.BalanceMonitor: The BalanceMonitor model to be created.
Returns: - model.BalanceMonitor: The created BalanceMonitor model. - error: An error if the monitor could not be created.
func (*Blnk) DeleteIdentity ¶
DeleteIdentity deletes an identity by its ID.
Parameters: - id string: The ID of the identity to delete.
Returns: - error: An error if the identity could not be deleted.
func (*Blnk) DeleteMatchingRule ¶ added in v0.7.0
DeleteMatchingRule deletes a matching rule by its ID. Parameters: - ctx: The context for managing the request. - id: The ID of the rule to delete. Returns an error if deletion fails.
func (*Blnk) DeleteMonitor ¶
DeleteMonitor deletes a balance monitor by its ID. It starts a tracing span, deletes the monitor, and records relevant events and errors.
Parameters: - ctx context.Context: The context for the operation. - id string: The ID of the monitor to delete.
Returns: - error: An error if the monitor could not be deleted.
func (*Blnk) GetAccount ¶
GetAccount retrieves an account by its ID. It fetches the account from the datasource and includes additional data as specified.
Parameters: - id string: The ID of the account to retrieve. - include []string: A slice of strings specifying additional data to include.
Returns: - *model.Account: A pointer to the Account model if found. - error: An error if the account could not be retrieved.
func (*Blnk) GetAccountByNumber ¶
GetAccountByNumber retrieves an account from the database by its account number.
Parameters: - id string: The account number of the account to retrieve.
Returns: - *model.Account: A pointer to the Account model if found. - error: An error if the account could not be retrieved.
func (*Blnk) GetAllAccounts ¶
GetAllAccounts retrieves all accounts from the database.
Returns: - []model.Account: A slice of Account models. - error: An error if the accounts could not be retrieved.
func (*Blnk) GetAllBalances ¶
GetAllBalances retrieves all balances. It starts a tracing span, fetches all balances, and records relevant events.
Parameters: - ctx context.Context: The context for the operation.
Returns: - []model.Balance: A slice of Balance models. - error: An error if the balances could not be retrieved.
func (*Blnk) GetAllIdentities ¶
GetAllIdentities retrieves all identities from the database.
Returns: - []model.Identity: A slice of Identity models. - error: An error if the identities could not be retrieved.
func (*Blnk) GetAllLedgers ¶
GetAllLedgers retrieves all ledgers from the datasource. It returns a slice of Ledger models and an error if the operation fails.
Returns: - []model.Ledger: A slice of Ledger models. - error: An error if the ledgers could not be retrieved.
func (*Blnk) GetAllMonitors ¶
GetAllMonitors retrieves all balance monitors. It starts a tracing span, fetches all monitors, and records relevant events.
Parameters: - ctx context.Context: The context for the operation.
Returns: - []model.BalanceMonitor: A slice of BalanceMonitor models. - error: An error if the monitors could not be retrieved.
func (*Blnk) GetAllTransactions ¶
func (l *Blnk) GetAllTransactions(limit, offset int) ([]model.Transaction, error)
GetAllTransactions retrieves all transactions from the datasource. It starts a tracing span, fetches all transactions, and records relevant events and errors.
Returns: - []model.Transaction: A slice of all retrieved Transaction models. - error: An error if the transactions could not be retrieved.
func (*Blnk) GetBalanceByID ¶
func (l *Blnk) GetBalanceByID(ctx context.Context, id string, include []string) (*model.Balance, error)
GetBalanceByID retrieves a balance by its ID. It starts a tracing span, fetches the balance, and records relevant events.
Parameters: - ctx context.Context: The context for the operation. - id string: The ID of the balance to retrieve. - include []string: A slice of strings specifying additional data to include.
Returns: - *model.Balance: A pointer to the Balance model if found. - error: An error if the balance could not be retrieved.
func (*Blnk) GetBalanceMonitors ¶
func (l *Blnk) GetBalanceMonitors(ctx context.Context, balanceID string) ([]model.BalanceMonitor, error)
GetBalanceMonitors retrieves all monitors for a given balance ID. It starts a tracing span, fetches the monitors, and records relevant events.
Parameters: - ctx context.Context: The context for the operation. - balanceID string: The ID of the balance for which to retrieve monitors.
Returns: - []model.BalanceMonitor: A slice of BalanceMonitor models. - error: An error if the monitors could not be retrieved.
func (*Blnk) GetIdentity ¶
GetIdentity retrieves an identity by its ID.
Parameters: - id string: The ID of the identity to retrieve.
Returns: - *model.Identity: A pointer to the Identity model if found. - error: An error if the identity could not be retrieved.
func (*Blnk) GetInflightTransactionsByParentID ¶ added in v0.7.0
func (l *Blnk) GetInflightTransactionsByParentID(ctx context.Context, parentTransactionID string, batchSize int, offset int64) ([]*model.Transaction, error)
GetInflightTransactionsByParentID retrieves inflight transactions by their parent transaction ID. It starts a tracing span, fetches the transactions from the datasource, and records relevant events and errors.
Parameters: - ctx context.Context: The context for the operation. - parentTransactionID string: The ID of the parent transaction. - batchSize int: The number of transactions to retrieve in a batch. - offset int64: The offset for pagination.
Returns: - []*model.Transaction: A slice of pointers to the retrieved Transaction models. - error: An error if the transactions could not be retrieved.
func (*Blnk) GetLedgerByID ¶
GetLedgerByID retrieves a ledger by its ID from the datasource. It returns a pointer to the Ledger model and an error if the operation fails.
Parameters: - id: A string representing the ID of the ledger to retrieve.
Returns: - *model.Ledger: A pointer to the Ledger model if found. - error: An error if the ledger could not be retrieved.
func (*Blnk) GetMatchingRule ¶ added in v0.7.0
GetMatchingRule retrieves a matching rule by its ID. Parameters: - ctx: The context for managing the request. - id: The ID of the matching rule to retrieve. Returns the matching rule, or an error if retrieval fails.
func (*Blnk) GetMonitorByID ¶
GetMonitorByID retrieves a balance monitor by its ID. It starts a tracing span, fetches the monitor, and records relevant events.
Parameters: - ctx context.Context: The context for the operation. - id string: The ID of the monitor to retrieve.
Returns: - *model.BalanceMonitor: A pointer to the BalanceMonitor model if found. - error: An error if the monitor could not be retrieved.
func (*Blnk) GetRefundableTransactionsByParentID ¶ added in v0.7.0
func (l *Blnk) GetRefundableTransactionsByParentID(ctx context.Context, parentTransactionID string, batchSize int, offset int64) ([]*model.Transaction, error)
GetRefundableTransactionsByParentID retrieves refundable transactions by their parent transaction ID. It starts a tracing span, fetches the transactions from the datasource, and records relevant events and errors.
Parameters: - ctx context.Context: The context for the operation. - parentTransactionID string: The ID of the parent transaction. - batchSize int: The number of transactions to retrieve in a batch. - offset int64: The offset for pagination.
Returns: - []*model.Transaction: A slice of pointers to the retrieved Transaction models. - error: An error if the transactions could not be retrieved.
func (*Blnk) GetTransaction ¶
func (l *Blnk) GetTransaction(ctx context.Context, TransactionID string) (*model.Transaction, error)
GetTransaction retrieves a transaction by its ID from the datasource. It starts a tracing span, fetches the transaction, and records relevant events and errors.
Parameters: - ctx context.Context: The context for the operation. - TransactionID string: The ID of the transaction to be retrieved.
Returns: - *model.Transaction: A pointer to the retrieved Transaction model. - error: An error if the transaction could not be retrieved.
func (*Blnk) GetTransactionByRef ¶
func (l *Blnk) GetTransactionByRef(ctx context.Context, reference string) (model.Transaction, error)
GetTransactionByRef retrieves a transaction by its reference from the datasource. It starts a tracing span, fetches the transaction by reference, and records relevant events and errors.
Parameters: - ctx context.Context: The context for the operation. - reference string: The reference of the transaction to be retrieved.
Returns: - model.Transaction: The retrieved Transaction model. - error: An error if the transaction could not be retrieved.
func (*Blnk) ListMatchingRules ¶ added in v0.7.0
ListMatchingRules retrieves all matching rules. Parameters: - ctx: The context for managing the request. Returns a list of matching rules, or an error if retrieval fails.
func (*Blnk) ProcessTransactionInBatches ¶ added in v0.7.0
func (l *Blnk) ProcessTransactionInBatches(ctx context.Context, parentTransactionID string, amount float64, maxWorkers int, streamMode bool, gt getTxns, tw transactionWorker) ([]*model.Transaction, error)
ProcessTransactionInBatches processes transactions in batches or streams them based on the provided mode. It starts a tracing span, initializes worker pools, fetches transactions, and processes them concurrently.
Parameters: - ctx context.Context: The context for the operation. - parentTransactionID string: The ID of the parent transaction. - amount float64: The amount to be processed in the transaction. - maxWorkers int: The maximum number of workers to process transactions concurrently. - streamMode bool: A flag indicating whether to process transactions in streaming mode. - gt getTxns: A function to retrieve transactions in batches. - tw transactionWorker: A function to process transactions.
Returns: - []*model.Transaction: A slice of pointers to the processed Transaction models. - error: An error if the transactions could not be processed.
func (*Blnk) QueueTransaction ¶
func (l *Blnk) QueueTransaction(ctx context.Context, transaction *model.Transaction) (*model.Transaction, error)
QueueTransaction queues a transaction by setting its status and metadata, attempting to split it if needed, and enqueuing it. It starts a tracing span, sets the transaction status and metadata, splits the transaction if necessary, and enqueues it.
Parameters: - ctx context.Context: The context for the operation. - transaction *model.Transaction: The transaction to be queued.
Returns: - *model.Transaction: A pointer to the queued Transaction model. - error: An error if the transaction could not be queued.
func (*Blnk) RecordTransaction ¶
func (l *Blnk) RecordTransaction(ctx context.Context, transaction *model.Transaction) (*model.Transaction, error)
RecordTransaction records a transaction by validating, processing balances, and finalizing the transaction. It starts a tracing span, acquires a lock, and performs the necessary steps to record the transaction.
Parameters: - ctx context.Context: The context for the operation. - transaction *model.Transaction: The transaction to be recorded.
Returns: - *model.Transaction: A pointer to the recorded Transaction model. - error: An error if the transaction could not be recorded.
func (*Blnk) RefundTransaction ¶
func (l *Blnk) RefundTransaction(ctx context.Context, transactionID string) (*model.Transaction, error)
RefundTransaction processes a refund for a given transaction by its ID. It starts a tracing span, retrieves the original transaction, validates its status, creates a new refund transaction, and queues it.
Parameters: - ctx context.Context: The context for the operation. - transactionID string: The ID of the transaction to be refunded.
Returns: - *model.Transaction: A pointer to the refunded Transaction model. - error: An error if the transaction could not be refunded.
func (*Blnk) RefundWorker ¶ added in v0.7.0
func (l *Blnk) RefundWorker(ctx context.Context, jobs <-chan *model.Transaction, results chan<- BatchJobResult, wg *sync.WaitGroup, amount float64)
RefundWorker processes refund transactions from the jobs channel and sends the results to the results channel. It starts a tracing span, processes each transaction, and records relevant events and errors.
Parameters: - ctx context.Context: The context for the operation. - jobs <-chan *model.Transaction: A channel from which transactions are received for processing. - results chan<- BatchJobResult: A channel to which the results of the processing are sent. - wg *sync.WaitGroup: A wait group to synchronize the completion of the worker. - amount float64: The amount to be processed in the transaction.
func (*Blnk) RejectTransaction ¶ added in v0.6.2
func (l *Blnk) RejectTransaction(ctx context.Context, transaction *model.Transaction, reason string) (*model.Transaction, error)
RejectTransaction rejects a transaction by updating its status and recording the rejection reason. It starts a tracing span, updates the transaction status and metadata, persists the transaction, and records relevant events and errors.
Parameters: - ctx context.Context: The context for the operation. - transaction *model.Transaction: The transaction to be rejected. - reason string: The reason for rejecting the transaction.
Returns: - *model.Transaction: A pointer to the rejected Transaction model. - error: An error if the transaction could not be recorded.
func (*Blnk) Search ¶ added in v0.6.0
func (l *Blnk) Search(collection string, query *api.SearchCollectionParams) (interface{}, error)
Search performs a search on the specified collection using the provided query parameters.
Parameters: - collection string: The name of the collection to search. - query *api.SearchCollectionParams: The search query parameters.
Returns: - interface{}: The search results. - error: An error if the search operation fails.
func (*Blnk) StartReconciliation ¶ added in v0.7.0
func (s *Blnk) StartReconciliation(ctx context.Context, uploadID string, strategy string, groupCriteria string, matchingRuleIDs []string, isDryRun bool) (string, error)
StartReconciliation initiates the reconciliation process by creating a new reconciliation entry and starting the process asynchronously. The process is detached to run in the background. Parameters: - ctx: The context controlling the reconciliation process. - uploadID: The ID of the uploaded transaction file to reconcile. - strategy: The reconciliation strategy to be used (e.g., "one_to_one"). - groupCriteria: Criteria to group transactions (optional). - matchingRuleIDs: The IDs of the rules used for matching transactions. - isDryRun: If true, the reconciliation will not commit changes (useful for testing). Returns: - string: The ID of the reconciliation process. - error: If the reconciliation fails to start.
func (*Blnk) UpdateIdentity ¶
UpdateIdentity updates an existing identity in the database.
Parameters: - identity *model.Identity: A pointer to the Identity model to be updated.
Returns: - error: An error if the identity could not be updated.
func (*Blnk) UpdateMatchingRule ¶ added in v0.7.0
func (s *Blnk) UpdateMatchingRule(ctx context.Context, rule model.MatchingRule) (*model.MatchingRule, error)
UpdateMatchingRule updates an existing matching rule. It retrieves the existing rule, validates the new data, and then updates the rule. Parameters: - ctx: The context for managing the request. - rule: The updated rule data. Returns the updated rule, or an error if validation or update fails.
func (*Blnk) UpdateMonitor ¶
UpdateMonitor updates an existing balance monitor. It starts a tracing span, updates the monitor, and records relevant events and errors.
Parameters: - ctx context.Context: The context for the operation. - monitor *model.BalanceMonitor: A pointer to the BalanceMonitor model to be updated.
Returns: - error: An error if the monitor could not be updated.
func (*Blnk) UpdateTransactionStatus ¶
UpdateTransactionStatus updates the status of a transaction by its ID in the datasource. It starts a tracing span, updates the transaction status, and records relevant events and errors.
Parameters: - ctx context.Context: The context for the operation. - id string: The ID of the transaction to be updated. - status string: The new status to be set for the transaction.
Returns: - error: An error if the transaction status could not be updated.
func (*Blnk) UploadExternalData ¶ added in v0.7.0
func (s *Blnk) UploadExternalData(ctx context.Context, source string, reader io.Reader, filename string) (string, int, error)
UploadExternalData handles the process of uploading external data by detecting file type, parsing, and storing it. Parameters: - ctx: The context for controlling execution. - source: The source of the external data. - reader: An io.Reader for reading the data. - filename: The name of the file being uploaded. Returns: - string: The ID of the upload. - int: The total number of records processed. - error: If any step of the process fails.
func (*Blnk) VoidInflightTransaction ¶ added in v0.6.0
func (l *Blnk) VoidInflightTransaction(ctx context.Context, transactionID string) (*model.Transaction, error)
VoidInflightTransaction voids an inflight transaction by validating it, calculating the remaining amount, and finalizing the void. It starts a tracing span, fetches and validates the inflight transaction, calculates the remaining amount, and finalizes the void.
Parameters: - ctx context.Context: The context for the operation. - transactionID string: The ID of the inflight transaction to be voided.
Returns: - *model.Transaction: A pointer to the voided Transaction model. - error: An error if the transaction could not be voided.
func (*Blnk) VoidWorker ¶ added in v0.7.0
func (l *Blnk) VoidWorker(ctx context.Context, jobs <-chan *model.Transaction, results chan<- BatchJobResult, wg *sync.WaitGroup, amount float64)
VoidWorker processes void transactions from the jobs channel and sends the results to the results channel. It starts a tracing span, processes each transaction, and records relevant events and errors.
Parameters: - ctx context.Context: The context for the operation. - jobs <-chan *model.Transaction: A channel from which transactions are received for processing. - results chan<- BatchJobResult: A channel to which the results of the processing are sent. - wg *sync.WaitGroup: A wait group to synchronize the completion of the worker. - amount float64: The amount to be processed in the transaction (not used in this function).
type MockBlnk ¶ added in v0.7.0
type MockBlnk struct { Blnk // contains filtered or unexported fields }
MockBlnk is a mock implementation of the Blnk struct for testing purposes.
func (*MockBlnk) GetTransaction ¶ added in v0.7.0
func (m *MockBlnk) GetTransaction(id string) (*model.Transaction, error)
GetTransaction retrieves a transaction by its ID using the mock implementation if provided. If no mock implementation is provided, it falls back to the actual GetTransaction method.
Parameters: - id string: The ID of the transaction to retrieve.
Returns: - *model.Transaction: A pointer to the Transaction model if found. - error: An error if the transaction could not be retrieved.
type NewWebhook ¶
type NewWebhook struct { Event string `json:"event"` // The event type that triggered the webhook. Payload interface{} `json:"data"` // The data associated with the event. }
NewWebhook represents the structure of a webhook notification. It includes an event type and associated payload data.
type NotificationPayload ¶ added in v0.6.2
type NotificationPayload struct { Table string `json:"table"` Data map[string]interface{} `json:"data"` }
NotificationPayload represents the payload structure for notifications, containing the table and data.
type Queue ¶
Queue represents a queue for handling various tasks.
func NewQueue ¶
func NewQueue(conf *config.Configuration) *Queue
NewQueue initializes a new Queue instance with the provided configuration.
Parameters: - conf *config.Configuration: The configuration for the queue.
Returns: - *Queue: A pointer to the newly created Queue instance.
func (*Queue) Enqueue ¶
Enqueue enqueues a transaction to the Redis queue.
Parameters: - ctx context.Context: The context for the operation. - transaction *model.Transaction: The transaction to be enqueued.
Returns: - error: An error if the transaction could not be enqueued.
func (*Queue) GetTransactionFromQueue ¶ added in v0.7.0
func (q *Queue) GetTransactionFromQueue(transactionID string) (*model.Transaction, error)
GetTransactionFromQueue retrieves a transaction from the queue by its ID.
Parameters: - transactionID string: The ID of the transaction to retrieve.
Returns: - *model.Transaction: A pointer to the Transaction model if found. - error: An error if the transaction could not be retrieved.
type TransactionTypePayload ¶
type TransactionTypePayload struct {
Data model.Transaction
}
TransactionTypePayload represents the payload for a transaction type.
type TypesenseClient ¶ added in v0.6.0
TypesenseClient wraps the Typesense client and provides methods to interact with it.
func NewTypesenseClient ¶ added in v0.6.0
func NewTypesenseClient(apiKey string, hosts []string) *TypesenseClient
NewTypesenseClient initializes and returns a new Typesense client instance.
func (*TypesenseClient) CreateCollection ¶ added in v0.6.0
func (t *TypesenseClient) CreateCollection(ctx context.Context, schema *api.CollectionSchema) (*api.CollectionResponse, error)
CreateCollection creates a collection in Typesense based on the provided schema. If the collection already exists, it will return without error.
func (*TypesenseClient) EnsureCollectionsExist ¶ added in v0.7.0
func (t *TypesenseClient) EnsureCollectionsExist(ctx context.Context) error
EnsureCollectionsExist ensures that all the necessary collections exist in the Typesense schema. If a collection doesn't exist, it will create the collection based on the latest schema.
func (*TypesenseClient) HandleNotification ¶ added in v0.6.2
func (t *TypesenseClient) HandleNotification(table string, data map[string]interface{}) error
HandleNotification processes incoming notifications and updates Typesense collections based on the table and data. It ensures the required fields exist and upserts the data into Typesense.
func (*TypesenseClient) MigrateTypeSenseSchema ¶ added in v0.7.0
func (t *TypesenseClient) MigrateTypeSenseSchema(ctx context.Context, collectionName string) error
MigrateTypeSenseSchema adds new fields from the latest schema to the existing collection schema in Typesense. This is useful when the schema has been updated, and new fields need to be added.
func (*TypesenseClient) Search ¶ added in v0.6.0
func (t *TypesenseClient) Search(ctx context.Context, collection string, searchParams *api.SearchCollectionParams) (*api.SearchResult, error)
Search performs a search query on a specific collection with the provided search parameters.