@@ -46,13 +46,13 @@ func NewKVCacheAwareScorer(ctx context.Context) (*KVCacheAwareScorer, error) {
4646 config := kvcache .NewDefaultConfig ()
4747
4848 redisAddr := os .Getenv (kvCacheRedisEnvVar )
49- if redisAddr ! = "" {
50- // to keep compatibility with deployments only specifying hostname:port: need to add protocol to front to enable parsing
51- if ! strings . HasPrefix ( redisAddr , "redis://" ) && ! strings . HasPrefix ( redisAddr , "rediss://" ) && ! strings . HasPrefix ( redisAddr , "unix://" ) {
52- redisAddr = "redis://" + redisAddr
53- }
54- } else {
55- return nil , fmt . Errorf ( "environment variable %s is not set" , kvCacheRedisEnvVar )
49+ if redisAddr = = "" {
50+ return nil , fmt . Errorf ( "environment variable '%s' is not set" , kvCacheRedisEnvVar )
51+ }
52+
53+ // to keep compatibility with deployments only specifying hostname:port: need to add protocol to front to enable parsing
54+ if ! strings . HasPrefix ( redisAddr , "redis://" ) && ! strings . HasPrefix ( redisAddr , "rediss://" ) && ! strings . HasPrefix ( redisAddr , "unix://" ) {
55+ redisAddr = "redis://" + redisAddr
5656 }
5757
5858 redisOpt , err := redis .ParseURL (redisAddr )
@@ -63,7 +63,7 @@ func NewKVCacheAwareScorer(ctx context.Context) (*KVCacheAwareScorer, error) {
6363
6464 hfToken := os .Getenv (huggingFaceTokenEnvVar )
6565 if hfToken == "" {
66- return nil , fmt .Errorf ("environment variable %s is not set" , huggingFaceTokenEnvVar )
66+ return nil , fmt .Errorf ("environment variable '%s' is not set" , huggingFaceTokenEnvVar )
6767 }
6868
6969 config .TokenizersPoolConfig .HuggingFaceToken = hfToken
@@ -76,37 +76,32 @@ func NewKVCacheAwareScorer(ctx context.Context) (*KVCacheAwareScorer, error) {
7676 go kvCacheIndexer .Run (ctx )
7777
7878 return & KVCacheAwareScorer {
79- name : KvCacheAwareScorerType ,
79+ typedName : plugins. TypedName { Type : KvCacheAwareScorerType } ,
8080 kvCacheIndexer : kvCacheIndexer ,
8181 }, nil
8282}
8383
8484// KVCacheAwareScorer uses the KVCacheIndexer to score pods based on KVCache awareness.
8585type KVCacheAwareScorer struct {
86- name string
86+ typedName plugins. TypedName
8787 kvCacheIndexer * kvcache.Indexer
8888}
8989
90- // Type returns the type of the scorer.
91- func (s * KVCacheAwareScorer ) Type () string {
92- return KvCacheAwareScorerType
93- }
94-
95- // Name returns the name of the instance of the filter.
96- func (s * KVCacheAwareScorer ) Name () string {
97- return s .name
90+ // TypedName returns the typed name of the plugin.
91+ func (s * KVCacheAwareScorer ) TypedName () plugins.TypedName {
92+ return s .typedName
9893}
9994
100- // WithName sets the name of the filter .
95+ // WithName sets the name of the plugin .
10196func (s * KVCacheAwareScorer ) WithName (name string ) * KVCacheAwareScorer {
102- s .name = name
97+ s .typedName . Name = name
10398 return s
10499}
105100
106101// Score scores the provided pod based on the KVCache index state.
107102// The returned scores are normalized to a range of 0-1.
108103func (s * KVCacheAwareScorer ) Score (ctx context.Context , _ * types.CycleState , request * types.LLMRequest , pods []types.Pod ) map [types.Pod ]float64 {
109- loggerDebug := log .FromContext (ctx ).WithName (s .name ).V (logutil .DEBUG )
104+ loggerDebug := log .FromContext (ctx ).WithName (s .typedName . String () ).V (logutil .DEBUG )
110105 if request == nil {
111106 loggerDebug .Info ("Request is nil, skipping scoring" )
112107 return nil
0 commit comments