app

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ReferralCodeExp     = regexp.MustCompile(`^[3-9|a-h|j-k|m|n|p|r-t|x|y]{4}-[3-9|a-h|j-k|m|n|p|r-t|x|y]{4}$`)
	RootReferralCodeExp = regexp.MustCompile(`^z[3-9|a-h|j-k|m|n|p|r-t|x|y]{3}-[3-9|a-h|j-k|m|n|p|r-t|x|y]{4}$`)
	KOLReferralCodeExp  = regexp.MustCompile(`^i[3-9|a-h|j-k|m|n|p|r-t|x|y]{3}-[3-9|a-h|j-k|m|n|p|r-t|x|y]{4}$`)
)

Functions

func ContextWithSignal

func ContextWithSignal(ctx context.Context) context.Context

ContextWithSignal sets up a signal listener, which will cancel the returned context when an interupt (SIGINT OR SIGTERM) is received.

func IsKOLReferralCode

func IsKOLReferralCode(code string) bool

func IsRootReferralCode

func IsRootReferralCode(code string) bool

func IsValidReferralCode

func IsValidReferralCode(code string) bool

IsValidReferralCode checks if a referral/root referral code is valid according to a regex pattern

func NewKOLReferralCode

func NewKOLReferralCode() (string, error)

NewKOLReferralCode creates a new kol referral code. This code is identical to a normal referral code, but the first character is always i. This means it will never validate as normal referral code.

func NewReferralCode

func NewReferralCode() (string, error)

func NewRootReferralCode

func NewRootReferralCode() (string, error)

NewRootReferralCode creates a new root referral code. root referral codes are similiar to referral codes, but the first character is always z. This means it will never validate as normal referral code. They are never created by a user and nobody gets a referral bonus from them.

func SleepContext

func SleepContext(ctx context.Context, duration time.Duration) error

SleepContext sleeps for the given duration or until the context is cancelled. If the context is cancelled, it returns the error from the context.

Types

type MultiRateLimiter

type MultiRateLimiter struct {
	// contains filtered or unexported fields
}

MultiRateLimiter is a rate limiter which can handle cases where there are multiple rate limits that need to be enforced on a single resource

func NewMultiRateLimiter

func NewMultiRateLimiter(limits []time.Duration, bursts []int) *MultiRateLimiter

func (*MultiRateLimiter) Wait

func (mrl *MultiRateLimiter) Wait(ctx context.Context) error

func (*MultiRateLimiter) WaitN

func (mrl *MultiRateLimiter) WaitN(ctx context.Context, n int) error

Jump to

Keyboard shortcuts

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