Documentation ¶
Index ¶
- Constants
- Variables
- func BatchInsertChannels(channels []*Channel) error
- func BatchRecordConsume(requestID string, requestAt time.Time, group string, code int, channelID int, ...) error
- func CacheCheckModelConfig(models []string) ([]string, []string)
- func CacheDeleteGroup(id string) error
- func CacheDeleteToken(key string) error
- func CacheGetEnabledChannelType2ModelConfigs() map[int][]*ModelConfig
- func CacheGetEnabledModels() []string
- func CacheIncreaseTokenUsedAmount(key string, amount float64) error
- func CacheSetGroup(group *Group) error
- func CacheSetToken(token *Token) error
- func CacheUpdateGroupQPM(id string, qpm int64) error
- func CacheUpdateGroupStatus(id string, status int) error
- func CacheUpdateTokenUsedAmount(key string, amount float64) error
- func CacheUpdateTokenUsedAmountOnlyIncrease(key string, amount float64) error
- func CheckModelConfig(models []string) ([]string, []string, error)
- func ClearLastTestErrorAt(id int) error
- func CloseDB() error
- func CreateConsumeError(requestID string, requestAt time.Time, group string, tokenName string, ...) error
- func CreateGroup(group *Group) error
- func DeleteChannelByID(id int) error
- func DeleteChannelsByIDs(ids []int) error
- func DeleteDisabledChannel() error
- func DeleteGroupByID(id string) (err error)
- func DeleteGroupLogs(groupID string) (int64, error)
- func DeleteGroupTokenByID(groupID string, id int) (err error)
- func DeleteGroupTokensByIDs(groupID string, ids []int) (err error)
- func DeleteGroupsByIDs(ids []string) (err error)
- func DeleteModelConfig(model string) error
- func DeleteModelConfigsByModels(models []string) error
- func DeleteOldLog(timestamp time.Time) (int64, error)
- func DeleteTokenByID(id int) (err error)
- func DeleteTokensByIDs(ids []int) (err error)
- func DisableChannelByID(id int) error
- func EnableChannelByID(id int) error
- func GetEnabledModel2Channels() map[string][]*Channel
- func GetTokenUsedAmount(id int) (float64, error)
- func GetTokenUsedAmountByKey(key string) (float64, error)
- func HandleNotFound(err error, errMsg ...string) error
- func HandleUpdateResult(result *gorm.DB, entityName string) error
- func InitChannelCache() error
- func InitDB()
- func InitLogDB()
- func InitModelConfigCache() error
- func InitOptionMap() error
- func InsertToken(token *Token, autoCreateGroup bool) error
- func OnConflictDoNothing() *gorm.DB
- func RecordConsumeLog(requestID string, requestAt time.Time, group string, code int, channelID int, ...) error
- func SaveModelConfig(config *ModelConfig) error
- func SaveModelConfigs(configs []*ModelConfig) error
- func SortModelConfigsFunc(i, j *ModelConfig) int
- func SumUsedQuota(startTimestamp time.Time, endTimestamp time.Time, modelName string, ...) (quota int64)
- func SumUsedToken(startTimestamp time.Time, endTimestamp time.Time, modelName string, ...) (token int)
- func SyncChannelCache(ctx context.Context, wg *sync.WaitGroup, frequency time.Duration)
- func SyncModelConfigCache(ctx context.Context, wg *sync.WaitGroup, frequency time.Duration)
- func SyncOptions(ctx context.Context, wg *sync.WaitGroup, frequency time.Duration)
- func UpdateChannel(channel *Channel) error
- func UpdateChannelStatusByID(id int, status int) error
- func UpdateChannelUsedAmount(id int, amount float64, requestCount int) error
- func UpdateGroupQPM(id string, qpm int64) (err error)
- func UpdateGroupRequestCount(id string, count int) error
- func UpdateGroupStatus(id string, status int) (err error)
- func UpdateGroupTokenName(group string, id int, name string) (err error)
- func UpdateGroupTokenStatus(group string, id int, status int) (err error)
- func UpdateGroupTokenStatusAndAccessedAt(group string, id int, status int) (err error)
- func UpdateGroupUsedAmount(id string, amount float64) error
- func UpdateGroupUsedAmountAndRequestCount(id string, amount float64, count int) error
- func UpdateOption(key string, value string) error
- func UpdateOptions(options map[string]string) error
- func UpdateToken(token *Token) (err error)
- func UpdateTokenName(id int, name string) (err error)
- func UpdateTokenStatus(id int, status int) (err error)
- func UpdateTokenStatusAndAccessedAt(id int, status int) (err error)
- func UpdateTokenUsedAmount(id int, amount float64, requestCount int) (err error)
- type Channel
- func CacheGetAllChannelByID(id int) (*Channel, bool)
- func CacheGetAllChannels() []*Channel
- func CacheGetEnabledChannelByID(id int) (*Channel, bool)
- func CacheGetEnabledChannels() []*Channel
- func CacheGetRandomSatisfiedChannel(model string) (*Channel, error)
- func GetAllChannels(onlyDisabled bool, omitKey bool) (channels []*Channel, err error)
- func GetChannelByID(id int, omitKey bool) (*Channel, error)
- func GetChannels(startIdx int, num int, onlyDisabled bool, omitKey bool, id int, name string, ...) (channels []*Channel, total int64, err error)
- func LoadChannelByID(id int) (*Channel, error)
- func LoadChannels() ([]*Channel, error)
- func LoadEnabledChannels() ([]*Channel, error)
- func SearchChannels(keyword string, startIdx int, num int, onlyDisabled bool, omitKey bool, id int, ...) (channels []*Channel, total int64, err error)
- func (c *Channel) BeforeDelete(tx *gorm.DB) (err error)
- func (c *Channel) BeforeSave(tx *gorm.DB) (err error)
- func (c *Channel) MarshalJSON() ([]byte, error)
- func (c *Channel) UpdateBalance(balance float64) error
- func (c *Channel) UpdateModelTest(testAt time.Time, model, actualModel string, mode int, took float64, ...) (*ChannelTest, error)
- type ChannelConfig
- type ChannelTest
- type ConsumeError
- type EmptyNullString
- type Group
- type GroupCache
- type Log
- func GetGroupLogs(group string, startTimestamp time.Time, endTimestamp time.Time, code int, ...) (logs []*Log, total int64, err error)
- func GetLogs(startTimestamp time.Time, endTimestamp time.Time, code int, modelName string, ...) (logs []*Log, total int64, err error)
- func SearchGroupLogs(group string, keyword string, page int, perPage int, code int, endpoint string, ...) (logs []*Log, total int64, err error)
- func SearchLogs(keyword string, page int, perPage int, code int, endpoint string, ...) (logs []*Log, total int64, err error)
- type LogStatistic
- type ModelConfig
- func CacheGetEnabledModelConfigs() []*ModelConfig
- func CacheGetModelConfig(model string) (*ModelConfig, bool)
- func GetAllModelConfigs() (configs []*ModelConfig, err error)
- func GetModelConfig(model string) (*ModelConfig, error)
- func GetModelConfigs(startIdx int, num int, model string) (configs []*ModelConfig, total int64, err error)
- func GetModelConfigsByModels(models []string) (configs []*ModelConfig, err error)
- func SearchModelConfigs(keyword string, startIdx int, num int, model string, owner ModelOwner) (configs []*ModelConfig, total int64, err error)
- type ModelConfigKey
- type ModelOwner
- type NotFoundError
- type Option
- type RequestDetail
- type Token
- func GetGroupTokenByID(group string, id int) (*Token, error)
- func GetGroupTokens(group string, startIdx int, num int, order string, status int) (tokens []*Token, total int64, err error)
- func GetTokenByID(id int) (*Token, error)
- func GetTokenByKey(key string) (*Token, error)
- func GetTokens(startIdx int, num int, order string, group string, status int) (tokens []*Token, total int64, err error)
- func SearchGroupTokens(group string, keyword string, startIdx int, num int, order string, status int, ...) (tokens []*Token, total int64, err error)
- func SearchTokens(keyword string, startIdx int, num int, order string, status int, name string, ...) (tokens []*Token, total int64, err error)
- type TokenCache
Constants ¶
View Source
const ( SyncFrequency = time.Minute * 3 TokenCacheKey = "token:%s" GroupCacheKey = "group:%s" )
View Source
const ( ChannelStatusUnknown = 0 ChannelStatusEnabled = 1 // don't use 0, 0 is the default value! ChannelStatusManuallyDisabled = 2 // also don't use 0 ChannelStatusAutoDisabled = 3 )
View Source
const ( GroupStatusEnabled = 1 // don't use 0, 0 is the default value! GroupStatusDisabled = 2 // also don't use 0 )
View Source
const ( TokenStatusEnabled = 1 // don't use 0, 0 is the default value! TokenStatusDisabled = 2 // also don't use 0 TokenStatusExpired = 3 TokenStatusExhausted = 4 )
View Source
const (
ErrChannelNotFound = "channel"
)
View Source
const (
ErrGroupNotFound = "group"
)
View Source
const ErrModelConfigNotFound = "model config"
View Source
const (
ErrTokenNotFound = "token"
)
Variables ¶
View Source
var ( DB *gorm.DB LogDB *gorm.DB )
View Source
var ErrUnknownOptionKey = errors.New("unknown option key")
Functions ¶
func BatchInsertChannels ¶
func BatchRecordConsume ¶
func BatchRecordConsume( requestID string, requestAt time.Time, group string, code int, channelID int, promptTokens int, completionTokens int, modelName string, tokenID int, tokenName string, amount float64, price float64, completionPrice float64, endpoint string, content string, mode int, requestDetail *RequestDetail, ) error
func CacheCheckModelConfig ¶
func CacheDeleteGroup ¶
func CacheDeleteToken ¶
func CacheGetEnabledChannelType2ModelConfigs ¶
func CacheGetEnabledChannelType2ModelConfigs() map[int][]*ModelConfig
CacheGetEnabledChannelType2ModelConfigs returns a map of channel type to enabled model configs
func CacheGetEnabledModels ¶
func CacheGetEnabledModels() []string
CacheGetEnabledModels returns a list of enabled model names
func CacheSetGroup ¶
func CacheSetToken ¶
func CacheUpdateGroupQPM ¶
func CacheUpdateGroupStatus ¶
func ClearLastTestErrorAt ¶
func CreateConsumeError ¶
func CreateGroup ¶
func DeleteChannelByID ¶
func DeleteChannelsByIDs ¶
func DeleteDisabledChannel ¶
func DeleteDisabledChannel() error
func DeleteGroupByID ¶
func DeleteGroupLogs ¶
func DeleteGroupTokenByID ¶
func DeleteGroupTokensByIDs ¶
func DeleteGroupsByIDs ¶
func DeleteModelConfig ¶
func DeleteTokenByID ¶
func DeleteTokensByIDs ¶
func DisableChannelByID ¶
func EnableChannelByID ¶
func GetEnabledModel2Channels ¶
GetEnabledModel2Channels returns a map of model name to enabled channels
func GetTokenUsedAmount ¶
func GetTokenUsedAmountByKey ¶
func HandleNotFound ¶
func HandleUpdateResult ¶
Helper function to handle update results
func InitChannelCache ¶
func InitChannelCache() error
InitChannelCache initializes the channel cache from database
func InitModelConfigCache ¶
func InitModelConfigCache() error
func InitOptionMap ¶
func InitOptionMap() error
func InsertToken ¶
func OnConflictDoNothing ¶
func RecordConsumeLog ¶
func RecordConsumeLog( requestID string, requestAt time.Time, group string, code int, channelID int, promptTokens int, completionTokens int, modelName string, tokenID int, tokenName string, amount float64, price float64, completionPrice float64, endpoint string, content string, mode int, requestDetail *RequestDetail, ) error
func SaveModelConfig ¶
func SaveModelConfig(config *ModelConfig) error
func SaveModelConfigs ¶
func SaveModelConfigs(configs []*ModelConfig) error
func SortModelConfigsFunc ¶
func SortModelConfigsFunc(i, j *ModelConfig) int
func SumUsedQuota ¶
func SumUsedToken ¶
func SyncChannelCache ¶
func SyncModelConfigCache ¶
func SyncOptions ¶
func UpdateChannel ¶
func UpdateChannelStatusByID ¶
func UpdateChannelUsedAmount ¶
func UpdateGroupQPM ¶
func UpdateGroupRequestCount ¶
func UpdateGroupStatus ¶
func UpdateGroupTokenName ¶
func UpdateGroupTokenStatus ¶
func UpdateGroupUsedAmount ¶
func UpdateOption ¶
func UpdateOptions ¶
func UpdateToken ¶
func UpdateTokenName ¶
func UpdateTokenStatus ¶
Types ¶
type Channel ¶
type Channel struct { CreatedAt time.Time `gorm:"index" json:"created_at"` AccessedAt time.Time `json:"accessed_at"` LastTestErrorAt time.Time `json:"last_test_error_at"` ChannelTests []*ChannelTest `gorm:"foreignKey:ChannelID;references:ID" json:"channel_tests"` BalanceUpdatedAt time.Time `json:"balance_updated_at"` ModelMapping map[string]string `gorm:"serializer:fastjson;type:text" json:"model_mapping"` Config ChannelConfig `gorm:"serializer:fastjson;type:text" json:"config"` Key string `gorm:"type:text;index" json:"key"` Name string `gorm:"index" json:"name"` BaseURL string `gorm:"index" json:"base_url"` Models []string `gorm:"serializer:fastjson;type:text" json:"models"` Balance float64 `json:"balance"` ID int `gorm:"primaryKey" json:"id"` UsedAmount float64 `gorm:"index" json:"used_amount"` RequestCount int `gorm:"index" json:"request_count"` Status int `gorm:"default:1;index" json:"status"` Type int `gorm:"default:0;index" json:"type"` Priority int32 `json:"priority"` }
func CacheGetAllChannelByID ¶
func CacheGetAllChannels ¶
func CacheGetAllChannels() []*Channel
func CacheGetEnabledChannels ¶
func CacheGetEnabledChannels() []*Channel
func GetAllChannels ¶
func GetChannels ¶
func LoadChannelByID ¶
func LoadChannels ¶
func LoadEnabledChannels ¶
func SearchChannels ¶
func (*Channel) BeforeSave ¶
check model config exist
func (*Channel) MarshalJSON ¶
func (*Channel) UpdateBalance ¶
type ChannelConfig ¶
type ChannelConfig struct { Region string `json:"region,omitempty"` SK string `json:"sk,omitempty"` AK string `json:"ak,omitempty"` UserID string `json:"user_id,omitempty"` APIVersion string `json:"api_version,omitempty"` Plugin string `json:"plugin,omitempty"` VertexAIProjectID string `json:"vertex_ai_project_id,omitempty"` VertexAIADC string `json:"vertex_ai_adc,omitempty"` }
type ChannelTest ¶
type ChannelTest struct { TestAt time.Time `json:"test_at"` Model string `gorm:"primaryKey" json:"model"` ActualModel string `json:"actual_model"` Response string `gorm:"type:text" json:"response"` ChannelName string `json:"channel_name"` ChannelType int `json:"channel_type"` ChannelID int `gorm:"primaryKey" json:"channel_id"` Took float64 `json:"took"` Success bool `json:"success"` Mode int `json:"mode"` Code int `json:"code"` }
func (*ChannelTest) MarshalJSON ¶
func (ct *ChannelTest) MarshalJSON() ([]byte, error)
type ConsumeError ¶
type ConsumeError struct { RequestAt time.Time `gorm:"index;index:idx_consume_error_group_reqat,priority:2" json:"request_at"` CreatedAt time.Time `json:"created_at"` GroupID string `gorm:"index;index:idx_consume_error_group_reqat,priority:1" json:"group_id"` RequestID string `gorm:"index" json:"request_id"` TokenName EmptyNullString `gorm:"not null" json:"token_name"` Model string `json:"model"` Content string `gorm:"type:text" json:"content"` ID int `gorm:"primaryKey" json:"id"` UsedAmount float64 `json:"used_amount"` TokenID int `json:"token_id"` }
func SearchConsumeError ¶
func (*ConsumeError) MarshalJSON ¶
func (c *ConsumeError) MarshalJSON() ([]byte, error)
type EmptyNullString ¶
type EmptyNullString string
func (*EmptyNullString) Scan ¶
func (ns *EmptyNullString) Scan(value any) error
Scan implements the [Scanner] interface.
func (EmptyNullString) String ¶
func (ns EmptyNullString) String() string
func (EmptyNullString) Value ¶
func (ns EmptyNullString) Value() (driver.Value, error)
Value implements the driver.Valuer interface.
type Group ¶
type Group struct { CreatedAt time.Time `json:"created_at"` AccessedAt time.Time `json:"accessed_at"` ID string `gorm:"primaryKey" json:"id"` Tokens []*Token `gorm:"foreignKey:GroupID" json:"-"` Status int `gorm:"default:1;index" json:"status"` UsedAmount float64 `gorm:"index" json:"used_amount"` QPM int64 `gorm:"index" json:"qpm"` RequestCount int `gorm:"index" json:"request_count"` }
func GetGroupByID ¶
func SearchGroup ¶
func (*Group) MarshalJSON ¶
func (*Group) ToGroupCache ¶
func (g *Group) ToGroupCache() *GroupCache
type GroupCache ¶
type GroupCache struct { ID string `json:"-" redis:"-"` Status int `json:"status" redis:"st"` QPM int64 `json:"qpm" redis:"q"` }
func CacheGetGroup ¶
func CacheGetGroup(id string) (*GroupCache, error)
type Log ¶
type Log struct { RequestDetail *RequestDetail `` /* 157-byte string literal not displayed */ RequestAt time.Time `` /* 143-byte string literal not displayed */ CreatedAt time.Time `` /* 143-byte string literal not displayed */ TokenName string `` /* 143-byte string literal not displayed */ Endpoint string `` /* 141-byte string literal not displayed */ Content string `` /* 140-byte string literal not displayed */ GroupID string `` /* 138-byte string literal not displayed */ Model string `` /* 138-byte string literal not displayed */ RequestID string `` /* 143-byte string literal not displayed */ Price float64 `json:"price"` ID int `` /* 135-byte string literal not displayed */ CompletionPrice float64 `json:"completion_price"` TokenID int `` /* 141-byte string literal not displayed */ UsedAmount float64 `` /* 144-byte string literal not displayed */ PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` ChannelID int `` /* 140-byte string literal not displayed */ Code int `` /* 137-byte string literal not displayed */ Mode int `json:"mode"` }
func GetGroupLogs ¶
func SearchGroupLogs ¶
func SearchGroupLogs(group string, keyword string, page int, perPage int, code int, endpoint string, requestID string, tokenID int, tokenName string, modelName string, content string, startTimestamp time.Time, endTimestamp time.Time, channelID int, order string, mode int) (logs []*Log, total int64, err error)
func SearchLogs ¶
func SearchLogs(keyword string, page int, perPage int, code int, endpoint string, groupID string, requestID string, tokenID int, tokenName string, modelName string, content string, startTimestamp time.Time, endTimestamp time.Time, channelID int, order string, mode int) (logs []*Log, total int64, err error)
func (*Log) MarshalJSON ¶
type LogStatistic ¶
type LogStatistic struct { Day string `gorm:"column:day"` Model string `gorm:"column:model"` RequestCount int `gorm:"column:request_count"` PromptTokens int `gorm:"column:prompt_tokens"` CompletionTokens int `gorm:"column:completion_tokens"` }
func SearchLogsByDayAndModel ¶
type ModelConfig ¶
type ModelConfig struct { CreatedAt time.Time `gorm:"index;autoCreateTime" json:"created_at"` UpdatedAt time.Time `gorm:"index;autoUpdateTime" json:"updated_at"` Config map[ModelConfigKey]any `gorm:"serializer:fastjson;type:text" json:"config,omitempty"` ImagePrices map[string]float64 `gorm:"serializer:fastjson" json:"image_prices"` Model string `gorm:"primaryKey" json:"model"` Owner ModelOwner `gorm:"type:varchar(255);index" json:"owner"` ImageMaxBatchSize int `json:"image_batch_size"` // relaymode/define.go Type int `json:"type"` InputPrice float64 `json:"input_price"` OutputPrice float64 `json:"output_price"` }
func CacheGetEnabledModelConfigs ¶
func CacheGetEnabledModelConfigs() []*ModelConfig
CacheGetEnabledModelConfigs returns a list of enabled model configs
func CacheGetModelConfig ¶
func CacheGetModelConfig(model string) (*ModelConfig, bool)
func GetAllModelConfigs ¶
func GetAllModelConfigs() (configs []*ModelConfig, err error)
func GetModelConfig ¶
func GetModelConfig(model string) (*ModelConfig, error)
func GetModelConfigs ¶
func GetModelConfigsByModels ¶
func GetModelConfigsByModels(models []string) (configs []*ModelConfig, err error)
func SearchModelConfigs ¶
func SearchModelConfigs(keyword string, startIdx int, num int, model string, owner ModelOwner) (configs []*ModelConfig, total int64, err error)
func (*ModelConfig) MarshalJSON ¶
func (c *ModelConfig) MarshalJSON() ([]byte, error)
type ModelConfigKey ¶
type ModelConfigKey string
const ( ModelConfigMaxContextTokensKey ModelConfigKey = "max_context_tokens" ModelConfigMaxInputTokensKey ModelConfigKey = "max_input_tokens" ModelConfigMaxOutputTokensKey ModelConfigKey = "max_output_tokens" ModelConfigToolChoiceKey ModelConfigKey = "tool_choice" ModelConfigFunctionCallingKey ModelConfigKey = "function_calling" ModelConfigSupportFormatsKey ModelConfigKey = "support_formats" ModelConfigSupportVoicesKey ModelConfigKey = "support_voices" )
type ModelOwner ¶
type ModelOwner string
const ( ModelOwnerOpenAI ModelOwner = "openai" ModelOwnerAlibaba ModelOwner = "alibaba" ModelOwnerTencent ModelOwner = "tencent" ModelOwnerXunfei ModelOwner = "xunfei" ModelOwnerDeepSeek ModelOwner = "deepseek" ModelOwnerMoonshot ModelOwner = "moonshot" ModelOwnerMiniMax ModelOwner = "minimax" ModelOwnerBaidu ModelOwner = "baidu" ModelOwnerGoogle ModelOwner = "google" ModelOwnerBAAI ModelOwner = "baai" ModelOwnerFunAudioLLM ModelOwner = "funaudiollm" ModelOwnerDoubao ModelOwner = "doubao" ModelOwnerFishAudio ModelOwner = "fishaudio" ModelOwnerChatGLM ModelOwner = "chatglm" ModelOwnerStabilityAI ModelOwner = "stabilityai" ModelOwnerNetease ModelOwner = "netease" ModelOwnerAI360 ModelOwner = "ai360" ModelOwnerAnthropic ModelOwner = "anthropic" ModelOwnerMeta ModelOwner = "meta" ModelOwnerBaichuan ModelOwner = "baichuan" ModelOwnerMistral ModelOwner = "mistral" ModelOwnerOpenChat ModelOwner = "openchat" ModelOwnerMicrosoft ModelOwner = "microsoft" ModelOwnerDefog ModelOwner = "defog" ModelOwnerNexusFlow ModelOwner = "nexusflow" ModelOwnerCohere ModelOwner = "cohere" ModelOwnerHuggingFace ModelOwner = "huggingface" ModelOwnerLingyiWanwu ModelOwner = "lingyiwanwu" ModelOwnerStepFun ModelOwner = "stepfun" )
type NotFoundError ¶
type NotFoundError string
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type Option ¶
func GetAllOption ¶
type RequestDetail ¶
type Token ¶
type Token struct { CreatedAt time.Time `json:"created_at"` ExpiredAt time.Time `json:"expired_at"` AccessedAt time.Time `gorm:"index" json:"accessed_at"` Group *Group `gorm:"foreignKey:GroupID" json:"-"` Key string `gorm:"type:char(48);uniqueIndex" json:"key"` Name EmptyNullString `gorm:"index;uniqueIndex:idx_group_name;not null" json:"name"` GroupID string `gorm:"index;uniqueIndex:idx_group_name" json:"group"` Subnet string `json:"subnet"` Models []string `gorm:"serializer:fastjson;type:text" json:"models"` Status int `gorm:"default:1;index" json:"status"` ID int `gorm:"primaryKey" json:"id"` Quota float64 `json:"quota"` UsedAmount float64 `gorm:"index" json:"used_amount"` RequestCount int `gorm:"index" json:"request_count"` }
func GetGroupTokens ¶
func GetTokenByID ¶
func GetTokenByKey ¶
func SearchGroupTokens ¶
func SearchTokens ¶
func (*Token) MarshalJSON ¶
func (*Token) ToTokenCache ¶
func (t *Token) ToTokenCache() *TokenCache
type TokenCache ¶
type TokenCache struct { ExpiredAt redisTime `json:"expired_at" redis:"e"` Group string `json:"group" redis:"g"` Key string `json:"-" redis:"-"` Name string `json:"name" redis:"n"` Subnet string `json:"subnet" redis:"s"` Models redisStringSlice `json:"models" redis:"m"` ID int `json:"id" redis:"i"` Status int `json:"status" redis:"st"` Quota float64 `json:"quota" redis:"q"` UsedAmount float64 `json:"used_amount" redis:"u"` }
func CacheGetTokenByKey ¶
func CacheGetTokenByKey(key string) (*TokenCache, error)
func ValidateAndGetToken ¶
func ValidateAndGetToken(key string) (token *TokenCache, err error)
Click to show internal directories.
Click to hide internal directories.