fix: update getToken function to include channelId in cache key
This commit is contained in:
parent
688a7fc670
commit
e52fde1895
@ -81,7 +81,7 @@ func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
|
|||||||
|
|
||||||
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *meta.Meta) error {
|
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *meta.Meta) error {
|
||||||
adaptor.SetupCommonRequestHeader(c, req, meta)
|
adaptor.SetupCommonRequestHeader(c, req, meta)
|
||||||
token, err := getToken(c, meta.Config.VertexAIADC)
|
token, err := getToken(c, meta.ChannelId, meta.Config.VertexAIADC)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,8 @@ var Cache = cache.New(50*time.Minute, 55*time.Minute)
|
|||||||
|
|
||||||
const defaultScope = "https://www.googleapis.com/auth/cloud-platform"
|
const defaultScope = "https://www.googleapis.com/auth/cloud-platform"
|
||||||
|
|
||||||
func getToken(ctx context.Context, adcJson string) (string, error) {
|
func getToken(ctx context.Context, channelId int, adcJson string) (string, error) {
|
||||||
cacheKey := "vertexai-token"
|
cacheKey := fmt.Sprintf("vertexai-token-%d", channelId)
|
||||||
if token, found := Cache.Get(cacheKey); found {
|
if token, found := Cache.Get(cacheKey); found {
|
||||||
return token.(string), nil
|
return token.(string), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user