@@ -18,17 +18,17 @@ import (
1818)
1919
2020const (
21- // ActiveRequestScorerType is the type of the ActiveRequestScorer
22- ActiveRequestScorerType = "active-request-scorer"
21+ // ActiveRequestType is the type of the ActiveRequest scorer.
22+ ActiveRequestType = "active-request-scorer"
2323
2424 // defaultRequestTimeout defines the default timeout for open requests to be
2525 // considered stale and removed from the cache.
2626 defaultRequestTimeout = 2 * time .Minute
2727)
2828
29- // ActiveRequestScorerParameters defines the parameters for the
30- // ActiveRequestScorer .
31- type ActiveRequestScorerParameters struct {
29+ // ActiveRequestParameters defines the parameters for the
30+ // ActiveRequest .
31+ type ActiveRequestParameters struct {
3232 // RequestTimeout defines the timeout for requests in seconds.
3333 // Once the request is "in-flight" for this duration, it is considered to
3434 // be timed out and dropped.
@@ -48,22 +48,22 @@ func (r *requestEntry) String() string {
4848}
4949
5050// compile-time type assertion
51- var _ framework.Scorer = & ActiveRequestScorer {}
51+ var _ framework.Scorer = & ActiveRequest {}
5252
53- // ActiveRequestScorerFactory defines the factory function for the ActiveRequestScorer .
54- func ActiveRequestScorerFactory (name string , rawParameters json.RawMessage , handle plugins.Handle ) (plugins.Plugin , error ) {
55- parameters := ActiveRequestScorerParameters {}
53+ // ActiveRequestFactory defines the factory function for the ActiveRequest scorer .
54+ func ActiveRequestFactory (name string , rawParameters json.RawMessage , handle plugins.Handle ) (plugins.Plugin , error ) {
55+ parameters := ActiveRequestParameters {}
5656 if rawParameters != nil {
5757 if err := json .Unmarshal (rawParameters , & parameters ); err != nil {
58- return nil , fmt .Errorf ("failed to parse the parameters of the '%s' scorer - %w" , ActiveRequestScorerType , err )
58+ return nil , fmt .Errorf ("failed to parse the parameters of the '%s' scorer - %w" , ActiveRequestType , err )
5959 }
6060 }
6161
62- return NewActiveRequestScorer (handle .Context (), & parameters ).WithName (name ), nil
62+ return NewActiveRequest (handle .Context (), & parameters ).WithName (name ), nil
6363}
6464
65- // NewActiveRequestScorer creates a new ActiveRequestScorer scorer.
66- func NewActiveRequestScorer (ctx context.Context , params * ActiveRequestScorerParameters ) * ActiveRequestScorer {
65+ // NewActiveRequest creates a new ActiveRequest scorer.
66+ func NewActiveRequest (ctx context.Context , params * ActiveRequestParameters ) * ActiveRequest {
6767 requestTimeout := defaultRequestTimeout
6868 logger := log .FromContext (ctx )
6969
@@ -83,8 +83,8 @@ func NewActiveRequestScorer(ctx context.Context, params *ActiveRequestScorerPara
8383 ttlcache .WithDisableTouchOnHit [string , * requestEntry ](),
8484 )
8585
86- scorer := & ActiveRequestScorer {
87- typedName : plugins.TypedName {Type : ActiveRequestScorerType },
86+ scorer := & ActiveRequest {
87+ typedName : plugins.TypedName {Type : ActiveRequestType },
8888 requestCache : requestCache ,
8989 podCounts : make (map [string ]int ),
9090 mutex : & sync.RWMutex {},
@@ -104,9 +104,9 @@ func NewActiveRequestScorer(ctx context.Context, params *ActiveRequestScorerPara
104104 return scorer
105105}
106106
107- // ActiveRequestScorer keeps track of individual requests being served
107+ // ActiveRequest keeps track of individual requests being served
108108// per pod.
109- type ActiveRequestScorer struct {
109+ type ActiveRequest struct {
110110 typedName plugins.TypedName
111111
112112 // requestCache stores individual request entries with unique composite keys (podName.requestID)
@@ -118,19 +118,19 @@ type ActiveRequestScorer struct {
118118}
119119
120120// TypedName returns the typed name of the plugin.
121- func (s * ActiveRequestScorer ) TypedName () plugins.TypedName {
121+ func (s * ActiveRequest ) TypedName () plugins.TypedName {
122122 return s .typedName
123123}
124124
125125// WithName sets the name of the plugin.
126- func (s * ActiveRequestScorer ) WithName (name string ) * ActiveRequestScorer {
126+ func (s * ActiveRequest ) WithName (name string ) * ActiveRequest {
127127 s .typedName .Name = name
128128 return s
129129}
130130
131131// Score scores the given pods based on the number of active requests
132132// being served by each pod. The score is normalized to a range of 0-1.
133- func (s * ActiveRequestScorer ) Score (ctx context.Context , _ * types.CycleState , _ * types.LLMRequest ,
133+ func (s * ActiveRequest ) Score (ctx context.Context , _ * types.CycleState , _ * types.LLMRequest ,
134134 pods []types.Pod ) map [types.Pod ]float64 {
135135 scoredPods := make (map [string ]int )
136136 maxCount := 0
@@ -164,7 +164,7 @@ func (s *ActiveRequestScorer) Score(ctx context.Context, _ *types.CycleState, _
164164// PreRequest is called before a request is sent to the target pod.
165165// It creates a new request entry in the cache with its own TTL and
166166// increments the pod count for fast lookup.
167- func (s * ActiveRequestScorer ) PreRequest (ctx context.Context , request * types.LLMRequest ,
167+ func (s * ActiveRequest ) PreRequest (ctx context.Context , request * types.LLMRequest ,
168168 schedulingResult * types.SchedulingResult , _ int ) {
169169 debugLogger := log .FromContext (ctx ).V (logutil .DEBUG )
170170
@@ -190,9 +190,9 @@ func (s *ActiveRequestScorer) PreRequest(ctx context.Context, request *types.LLM
190190// PostResponse is called after a response is sent to the client.
191191// It removes the specific request entry from the cache and decrements
192192// the pod count.
193- func (s * ActiveRequestScorer ) PostResponse (ctx context.Context , request * types.LLMRequest ,
193+ func (s * ActiveRequest ) PostResponse (ctx context.Context , request * types.LLMRequest ,
194194 _ * requestcontrol.Response , targetPod * backend.Pod ) {
195- debugLogger := log .FromContext (ctx ).V (logutil .DEBUG ).WithName ("ActiveRequestScorer .PostResponse" )
195+ debugLogger := log .FromContext (ctx ).V (logutil .DEBUG ).WithName ("ActiveRequest .PostResponse" )
196196 if targetPod == nil {
197197 debugLogger .Info ("Skipping PostResponse because targetPod is nil" )
198198 return
@@ -209,7 +209,7 @@ func (s *ActiveRequestScorer) PostResponse(ctx context.Context, request *types.L
209209}
210210
211211// incrementPodCount increments the request count for a pod.
212- func (s * ActiveRequestScorer ) incrementPodCount (podName string ) {
212+ func (s * ActiveRequest ) incrementPodCount (podName string ) {
213213 s .mutex .Lock ()
214214 defer s .mutex .Unlock ()
215215
@@ -218,7 +218,7 @@ func (s *ActiveRequestScorer) incrementPodCount(podName string) {
218218
219219// decrementPodCount decrements the request count for a pod and removes
220220// the entry if count reaches zero.
221- func (s * ActiveRequestScorer ) decrementPodCount (podName string ) {
221+ func (s * ActiveRequest ) decrementPodCount (podName string ) {
222222 s .mutex .Lock ()
223223 defer s .mutex .Unlock ()
224224
0 commit comments