Documentation ¶
Index ¶
- Variables
- func ContextWithSignal(ctx context.Context) context.Context
- func IsKOLReferralCode(code string) bool
- func IsRootReferralCode(code string) bool
- func IsValidReferralCode(code string) bool
- func NewKOLReferralCode() (string, error)
- func NewReferralCode() (string, error)
- func NewRootReferralCode() (string, error)
- func SleepContext(ctx context.Context, duration time.Duration) error
- type MultiRateLimiter
Constants ¶
This section is empty.
Variables ¶
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 ¶
ContextWithSignal sets up a signal listener, which will cancel the returned context when an interupt (SIGINT OR SIGTERM) is received.
func IsKOLReferralCode ¶
func IsRootReferralCode ¶
func IsValidReferralCode ¶
IsValidReferralCode checks if a referral/root referral code is valid according to a regex pattern
func NewKOLReferralCode ¶
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 NewRootReferralCode ¶
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.
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