common

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnonymizeKey

func AnonymizeKey(key string) string

AnonymizeKey will anonymize the provided key

func ConvertTimeToInterval

func ConvertTimeToInterval(timeToWait time.Duration) string

func CronJobStarter

func CronJobStarter(ctx context.Context, handler func(), timeToCall time.Duration)

CronJobStarter is able to start a go routine that periodically calls the provided handler. The time between calls is provided as timeToCall

func GenerateKey

func GenerateKey() string

GenerateKey will generate a new key

func GetAllPerformanceIntervals

func GetAllPerformanceIntervals() []string

GetAllPerformanceIntervals will output all the intervals defined

func NewKeyCounter

func NewKeyCounter() *keyCounter

NewKeyCounter creates a new instance of type key counter

func NewKeysQueue

func NewKeysQueue(keys ...string) *keysQueue

NewKeysQueue will hold a unique keys queue

func ProcessUserDetails

func ProcessUserDetails(userDetails *UsersDetails)

ProcessUserDetails implements a high-level logic to set 3 fields on the provided user details object: the ProcessedAccountType, CryptoPaymentInitiated and IsUnlimited

Types

type AccessKeyDetails

type AccessKeyDetails struct {
	MaxRequests    uint64
	GlobalCounter  uint64
	KeyCounter     uint64
	Username       string
	HashedPassword string
	IsAdmin        bool
}

AccessKeyDetails holds details about an access key

type AccountInfo

type AccountInfo struct {
	PaymentID uint64 `json:"paymentID"`
	Address   string `json:"address"`
	Credits   uint64 `json:"credits"`
}

AccountInfo response from account endpoint

type AccountType

type AccountType string

AccountType describes the account type

const FreeAccountType AccountType = "free"

FreeAccountType defines the free account type, usually throttled

const PremiumAccountType AccountType = "premium"

PremiumAccountType defines the premium account type, un-throttled

type Claims

type Claims struct {
	Username string `json:"username"`
	IsAdmin  bool   `json:"is_admin"`
	jwt.RegisteredClaims
}

Claims struct holds the JWT claims

type CreateAddressResponse

type CreateAddressResponse struct {
	PaymentID uint64 `json:"paymentID"`
}

CreateAddressResponse response from create-address endpoint

type CryptoPaymentConfig

type CryptoPaymentConfig struct {
	IsContractPaused bool    `json:"isContractPaused"`
	CreditsPerEGLD   uint64  `json:"creditsPerEGLD"`
	WalletURL        string  `json:"walletURL"`
	ExplorerURL      string  `json:"explorerURL"`
	ContractAddress  string  `json:"contractAddress"`
	MinimumBalance   float64 `json:"minimumBalance"`
}

CryptoPaymentConfig response from crypto-payment service

type FileLoggingHandler

type FileLoggingHandler interface {
	ChangeFileLifeSpan(newDuration time.Duration, newSizeInMB uint64) error
	Close() error
	IsInterfaceNil() bool
}

FileLoggingHandler will handle log file rotation

type UsersDetails

type UsersDetails struct {
	MaxRequests            uint64      `json:"MaxRequests"`
	GlobalCounter          uint64      `json:"GlobalCounter"`
	Username               string      `json:"Username"`
	HashedPassword         string      `json:"HashedPassword"`
	IsPremium              bool        `json:"IsPremium"`
	ProcessedAccountType   AccountType `json:"AccountType"`
	CryptoPaymentInitiated bool        `json:"CryptoPaymentInitiated"`
	IsUnlimited            bool        `json:"IsUnlimited"`
	IsActive               bool        `json:"IsActive"`
	IsAdmin                bool        `json:"IsAdmin"`
	CryptoPaymentID        uint64      `json:"PaymentID"`
	SCMaxRequests          uint64      `json:"SCMaxRequests"`
}

UsersDetails holds details about a user

Jump to

Keyboard shortcuts

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