utils

package
v3.6.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxRetries     = 5
	InitialBackoff = 500 * time.Millisecond
	MaxBackoff     = 10 * time.Second
	BackoffFactor  = 2.0
)
View Source
const BalanceSyncLockPrefix = "lock:{transactions}:balance-sync:"
View Source
const BalanceSyncScheduleKey = "schedule:{transactions}:balance-sync"

Variables

View Source
var (
	BalanceSynced = metrics.Metric{
		Name:        "balance_synced",
		Unit:        "1",
		Description: "Measures the number of balances synced.",
	}
)

Functions

func AccountingRoutesInternalKey added in v3.5.0

func AccountingRoutesInternalKey(organizationID, ledgerID, key uuid.UUID) string

AccountingRoutesInternalKey returns a key with the following format to be used on redis cluster: "accounting_routes:{organizationID:ledgerID:key}"

func BalanceInternalKey added in v3.3.6

func BalanceInternalKey(organizationID, ledgerID uuid.UUID, key string) string

BalanceInternalKey returns a key with the following format to be used on redis cluster: "balance:{transactions}:organizationID:ledgerID:key"

func BoolPtr added in v3.5.0

func BoolPtr(b bool) *bool

func EnvFallback added in v3.5.0

func EnvFallback(prefixed, fallback string) string

EnvFallback returns the prefixed value if not empty, otherwise returns the fallback value. This is useful for supporting both prefixed env vars (e.g., DB_ONBOARDING_HOST) with fallback to non-prefixed (e.g., DB_HOST) for backward compatibility.

func EnvFallbackInt added in v3.5.0

func EnvFallbackInt(prefixed, fallback int) int

EnvFallbackInt returns the prefixed value if not zero, otherwise returns the fallback value. This is useful for supporting both prefixed env vars with fallback to non-prefixed for backward compatibility.

func Float64Ptr added in v3.5.0

func Float64Ptr(f64 float64) *float64

func FullJitter

func FullJitter(baseDelay time.Duration) time.Duration

FullJitter returns a random delay between [0, baseDelay], capped by MaxBackoff.

func IdempotencyInternalKey added in v3.5.0

func IdempotencyInternalKey(organizationID, ledgerID uuid.UUID, key string) string

IdempotencyInternalKey returns a key with the following format to be used on redis cluster: "idempotency:{organizationID:ledgerID:key}"

func IdempotencyReverseKey added in v3.3.11

func IdempotencyReverseKey(organizationID, ledgerID uuid.UUID, transactionID string) string

IdempotencyReverseKey returns a key with the following format to be used on redis cluster: "idempotency_reverse:{organizationID:ledgerID}:transactionID" This key maps a transactionID to its idempotency key for reverse lookups.

func IntPtr added in v3.5.0

func IntPtr(i int) *int

func NextBackoff

func NextBackoff(current time.Duration) time.Duration

NextBackoff calculates the next exponential backoff, respecting the MaxBackoff capped.

func PendingTransactionLockKey added in v3.5.0

func PendingTransactionLockKey(organizationID, ledgerID uuid.UUID, transactionID string) string

PendingTransactionLockKey returns a key with the following format to be used on redis cluster: "pending_transaction:{transaction}:organizationID:ledgerID:transactionID" This key is used to lock pending transactions during commit/cancel operations.

func RedisConsumerLockKey added in v3.3.11

func RedisConsumerLockKey(organizationID, ledgerID uuid.UUID, transactionID string) string

RedisConsumerLockKey returns a key with the following format to be used on redis cluster: "redis_consumer_lock:{organizationID:ledgerID}:transactionID" This key is used to prevent duplicate processing of the same transaction across multiple pods.

func SafeTimePtr added in v3.5.0

func SafeTimePtr(t *time.Time) time.Time

SafeTimePtr safely dereferences a time pointer, returning zero time if nil

func SanitizeAccountAliases added in v3.3.13

func SanitizeAccountAliases(parserDSL *pkgTransaction.Transaction)

SanitizeAccountAliases cleans the AccountAlias fields in a Transaction's FromTo entries. This is necessary because HandleAccountFields mutates aliases in-place using ConcatAlias, producing formats like "0#@alias#key". SplitAlias extracts the original alias back.

func StringPtr added in v3.5.0

func StringPtr(s string) *string

func TransactionInternalKey added in v3.3.6

func TransactionInternalKey(organizationID, ledgerID uuid.UUID, key string) string

TransactionInternalKey returns a key with the following format to be used on redis cluster: "transaction:{transactions}:organizationID:ledgerID:key"

func ValidateAccountType added in v3.5.0

func ValidateAccountType(t string) error

ValidateAccountType validate type values of accounts

func ValidateCode added in v3.5.0

func ValidateCode(code string) error

func ValidateCountryAddress added in v3.5.0

func ValidateCountryAddress(country string) error

ValidateCountryAddress validate if country in object address contains in countries list using ISO 3166-1 alpha-2

func ValidateCurrency added in v3.5.0

func ValidateCurrency(code string) error

ValidateCurrency validate if code contains in currencies list using ISO 4217

func ValidateType added in v3.5.0

func ValidateType(t string) error

ValidateType validate type values of currencies

Types

This section is empty.

Jump to

Keyboard shortcuts

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