common

package
v0.0.0-...-d98d1a9 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UsingSQLite     = false
	UsingPostgreSQL = false
	UsingMySQL      = false
)
View Source
var (
	SQLitePath        = "aiproxy.db"
	SQLiteBusyTimeout = env.Int("SQLITE_BUSY_TIMEOUT", 3000)
)
View Source
var (
	Port   = flag.Int("port", 3000, "the listening port")
	LogDir = flag.String("log-dir", "", "specify the log directory")
)
View Source
var (
	RDB          *redis.Client
	RedisEnabled = false
)
View Source
var StartTime = time.Now().UnixMilli() // unit: millisecond

Functions

func GetRequestBody

func GetRequestBody(c *gin.Context) ([]byte, error)

func Init

func Init()

func InitRedisClient

func InitRedisClient() (err error)

InitRedisClient This function is called after init()

func RedisDel

func RedisDel(key string) error

func RedisGet

func RedisGet(key string) (string, error)

func RedisSet

func RedisSet(key string, value string, expiration time.Duration) error

func SetEventStreamHeaders

func SetEventStreamHeaders(c *gin.Context)

func UnmarshalBodyReusable

func UnmarshalBodyReusable(c *gin.Context, v any) error

Types

type CustomEvent

type CustomEvent struct {
	Data  string
	Event string
	ID    string
	Retry uint
}

func (CustomEvent) Render

func (r CustomEvent) Render(w http.ResponseWriter) error

func (CustomEvent) WriteContentType

func (r CustomEvent) WriteContentType(w http.ResponseWriter)

type InMemoryRateLimiter

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

func (*InMemoryRateLimiter) Init

func (l *InMemoryRateLimiter) Init(expirationDuration time.Duration)

func (*InMemoryRateLimiter) Request

func (l *InMemoryRateLimiter) Request(key string, maxRequestNum int, duration time.Duration) bool

Request parameter duration's unit is seconds

type RateLimitWindow

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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