web

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	MAX_RANDOM_NUMBER             = 256
	SALT_ONE_LENGTH               = 8
	SALT_TWO_LENGTH               = 8
	SALT_ONE_SHIFT                = SALT_TWO_LENGTH
	INCREASE_COUNTER_SHIFT        = SALT_TWO_LENGTH + SALT_ONE_LENGTH
	AUTO_ID_GENERATOR_COUNTER_KEY = "auto_id_generator_counter_key"
)

Variables

View Source
var (
	SHORT_URL_INFO_INDEX          = "short_url_info_index"
	SHORT_URL_INFO_INDEX_DOC_TYPE = "short_url_info_index_doc_type"

	BASE_STR  = "RScdTU567rstu89ABCDijnopEFGefwxHIJ01klm2ghqv34KLMNOPQVWXYZabyz"
	BASE_CHAR = []string{"R", "S", "c", "d", "T", "U", "5", "6", "7", "r", "s", "t", "u", "8", "9", "A", "B", "C", "D", "i", "j", "n", "o", "p", "E", "F", "G", "e", "f", "w", "x", "H", "I", "J", "0", "1", "k", "l", "m", "2", "g", "h", "q", "v", "3", "4", "K", "L", "M", "N", "O", "P", "Q", "V", "W", "X", "Y", "Z", "a", "b", "y", "z"}
)

Functions

func Char2Int added in v0.2.3

func Char2Int(code string, base uint64) (uint64, error)

func GenAutoId added in v0.2.3

func GenAutoId(client *redisc.RedisCli) uint64

func GenAutoIdByClu added in v0.2.3

func GenAutoIdByClu(client *redisc.RedisClusterCli) uint64

func GenAutoIdByKey added in v0.2.4

func GenAutoIdByKey(client *redisc.RedisCli, counterGroupKey string) uint64

func GenAutoIdByKeyClu added in v0.2.4

func GenAutoIdByKeyClu(client *redisc.RedisClusterCli, counterGroupKey string) uint64

func GenAutoIds added in v0.2.3

func GenAutoIds(n uint64, client *redisc.RedisCli) []uint64

func GenAutoIdsByClu added in v0.2.3

func GenAutoIdsByClu(n uint64, client *redisc.RedisClusterCli) []uint64

func GenAutoIdsByKey added in v0.2.4

func GenAutoIdsByKey(n uint64, client *redisc.RedisCli, counterGroupKey string) []uint64

func GenAutoIdsByKeyClu added in v0.2.4

func GenAutoIdsByKeyClu(n uint64, client *redisc.RedisClusterCli, counterGroupKey string) []uint64

func Int2Char added in v0.2.3

func Int2Char(number, base uint64) (string, error)

func IsAllowedByMap

func IsAllowedByMap(userId, actionKey string, capacity int64, leakingRate float64) bool

func IsAllowedByRedis

func IsAllowedByRedis(userId, actionKey string, capacity int64, leakingRate float64, client *redisc.RedisCli) bool

func IsAllowedByRedisCluster

func IsAllowedByRedisCluster(userId, actionKey string, capacity int64, leakingRate float64, client *redisc.RedisClusterCli) bool

func IsLimitedByMap

func IsLimitedByMap(userId, actionKey string, capacity int, leakingRate float64) bool

func IsLimitedByRedis

func IsLimitedByRedis(userId, actionKey string, capacity int, leakingRate float64, client *redisc.RedisCli) bool

func IsLimitedByRedisCluster

func IsLimitedByRedisCluster(userId, actionKey string, capacity int, leakingRate float64, client *redisc.RedisClusterCli) bool

Types

type ShortUrl added in v0.2.3

type ShortUrl struct {
	BaseUrl  string                  // The url or domain name of the server, e.g. http://127.0.0.1:8080/api/d/
	Rediscli *redisc.RedisCli        // redis Standalone Client or Cluster Either one can be initialized
	Redisclu *redisc.RedisClusterCli // redis Standalone Client or Cluster Either one can be initialized
	Esc7     *esc.EsClient7          // Just choose any one of the different versions of ES to initialize
	Esc8     *esc.EsClient8          // Just choose any one of the different versions of ES to initialize
}

func (*ShortUrl) ConvLongUrl added in v0.2.3

func (su *ShortUrl) ConvLongUrl(shortUrl string) (string, error)

func (*ShortUrl) GenShortUrl added in v0.2.3

func (su *ShortUrl) GenShortUrl(longUrl string) (string, error)

Jump to

Keyboard shortcuts

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