util

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIN_SYNC_TIMEOUT     time.Duration = 10 * time.Second
	SEND_TIMEOUT         time.Duration = 10 * time.Second
	HEALTH_CHECK_TIEMOUT time.Duration = 5 * time.Second
)
View Source
const (
	DefaultFailedSqlTxInitMsg                    string = "An error occurred while initiating an SQL transaction."
	DefaultFailedSqlQueryMsg                     string = "An error occurred while executing a SQL query."
	DefaultFailedScanningToPostgresqlDataTypeMsg string = "An error occurred while scanning the value into a PostgreSQL data type."
	DefaultFailedFetchingDaemonMsg               string = "An error occurred while fetching."

	FailedStringToPgUUIDMappingMsg string = "An error occurred while converting the string to the PostgreSQL UUID data type."

	InvalidUserIdInvalidUUIDMsg      string = "Invalid userId (invalid UUID)."
	InvalidUserIdUserExistsMsg       string = "Invalid userId (user exists)."
	InvalidUserIdUserDoesNotExistMsg string = "Invalid userId (user does not exist)."

	InvoiceAmountBelow0ErrorMsg      string = "Invoice amount can't be below 0."
	InvoiceErrorWhileHandlingMsg     string = "An error occurred while handling invoice."
	InvoiceStreamSendingDataErrorMsg string = "An error occurred while sending data."
	InvoiceStreamClosedErrorMsg      string = "Stream has been closed."
)
View Source
const (
	RequestIdKey   string     = "request-id"
	MetadataCtxKey contextKey = "metadata"
)
View Source
const (
	RequestIdLogKey = "requestId"
)

Variables

View Source
var (
	InvalidNetworkTypeErr error = errors.New("invalid network type")
)

Functions

func DbCoinToPbCoin

func DbCoinToPbCoin(coin db.CoinType) (pb_v1.CoinType, error)

func DbInvoiceStatusToPbInvoiceStatus

func DbInvoiceStatusToPbInvoiceStatus(status db.InvoiceStatusType) (pb_v1.InvoiceStatusType, error)

func DbInvoiceToPbInvoice

func DbInvoiceToPbInvoice(invoice *db.Invoice) *pb_v1.Invoice

func GetMapKeys added in v0.7.0

func GetMapKeys[K comparable, V any](m map[K]V) []K

func GetOptionOrEnvValue added in v0.4.0

func GetOptionOrEnvValue(env string, opt string) string

func GetRequestIdOrEmptyString added in v0.4.0

func GetRequestIdOrEmptyString(ctx context.Context) string

func InitDbQueriesWithTx

func InitDbQueriesWithTx(ctx context.Context, dbConnPool *pgxpool.Pool) (*db.Queries, pgx.Tx, error)

func PbCoinToDbCoin

func PbCoinToDbCoin(coin pb_v1.CoinType) (db.CoinType, error)

func PbNewInvoiceToProcessorNewInvoice

func PbNewInvoiceToProcessorNewInvoice(req *pb_v1.CreateInvoiceRequest) *dto.NewInvoiceRequest

func PgUUIDToString

func PgUUIDToString(uuid pgtype.UUID) string

func SliceToSet added in v0.7.0

func SliceToSet[T comparable](s []T) map[T]bool

func StringToPgUUID

func StringToPgUUID(uuidStr string) (*pgtype.UUID, error)

Types

type CustomMetadata added in v0.4.0

type CustomMetadata struct {
	RequestId string
}

type SyncMapTypeSafe

type SyncMapTypeSafe[K any, V any] struct {
	// contains filtered or unexported fields
}

func (*SyncMapTypeSafe[K, V]) Delete

func (m *SyncMapTypeSafe[K, V]) Delete(key K)

func (*SyncMapTypeSafe[K, V]) Load

func (m *SyncMapTypeSafe[K, V]) Load(key K) (value V, ok bool)

func (*SyncMapTypeSafe[K, V]) LoadAndDelete

func (m *SyncMapTypeSafe[K, V]) LoadAndDelete(key K) (value V, loaded bool)

func (*SyncMapTypeSafe[K, V]) LoadOrStore

func (m *SyncMapTypeSafe[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)

func (*SyncMapTypeSafe[K, V]) Range

func (m *SyncMapTypeSafe[K, V]) Range(f func(key K, value V) bool)

func (*SyncMapTypeSafe[K, V]) Store

func (m *SyncMapTypeSafe[K, V]) Store(key K, value V)

Jump to

Keyboard shortcuts

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