Repository: kubernetes-sigs/gateway-api-inference-extension

Issue:
Standardize the use of plugins.TypedName as key
As part of #1901, two comments were made with respect to use of `plugins.TypedName`:
- consistently use variable name in plugins (currently both `typedName` and `tn` are used)
- decide on consisten use of `TypedName.Type`, `TypedName.Name` or `TypedName.String()` as the key used for lookups, configruation references, logging, etc.

/kind cleanup

/cc @nirrozenbaum 

Discussion:
@rohithnarasimha: hi @elevran 
I’d like to take this issue.
can you please assign the issue on me@elevran: /assign @rohithnarasimha 
Can you please handle only the typedName changes for now? Note that #1911 addresses the change in the datalayer package so no need to do that.

We still need to decide on use to type, name, both for keys (cc: @shmuelk @nirrozenbaum)

Solution patch:
diff --git a/pkg/epp/scheduling/framework/plugins/multi/slo_aware_router/scorer.go b/pkg/epp/scheduling/framework/plugins/multi/slo_aware_router/scorer.go
index c72ec58..3b4da59 100644
--- a/pkg/epp/scheduling/framework/plugins/multi/slo_aware_router/scorer.go
+++ b/pkg/epp/scheduling/framework/plugins/multi/slo_aware_router/scorer.go
@@ -37,7 +37,7 @@ import (
 )
 
 type SLOAwareRouter struct {
-	tn                  plugins.TypedName
+	typedName           plugins.TypedName
 	latencypredictor    latencypredictor.PredictorInterface
 	runningRequestLists map[types.NamespacedName]*requestPriorityQueue
 	sloContextStore     sync.Map // map[string]*SLORequestContext
@@ -108,7 +108,7 @@ func NewSLOAwareRouter(config Config, predictor latencypredictor.PredictorInterf
 	}
 
 	return &SLOAwareRouter{
-		tn:                  plugins.TypedName{Type: SLOAwareRouterPluginType, Name: SLOAwareRouterPluginType},
+		typedName:           plugins.TypedName{Type: SLOAwareRouterPluginType, Name: SLOAwareRouterPluginType},
 		latencypredictor:    predictor,
 		runningRequestLists: make(map[types.NamespacedName]*requestPriorityQueue),
 		sloContextStore:     sync.Map{},
@@ -132,11 +132,11 @@ func startPredictor(handle plugins.Handle) (latencypredictor.PredictorInterface,
 }
 
 func (s *SLOAwareRouter) TypedName() plugins.TypedName {
-	return s.tn
+	return s.typedName
 }
 
 func (s *SLOAwareRouter) WithName(name string) *SLOAwareRouter {
-	s.tn.Name = name
+	s.typedName.Name = name
 	return s
 }
 
diff --git a/pkg/epp/scheduling/framework/plugins/scorer/lora_affinity.go b/pkg/epp/scheduling/framework/plugins/scorer/lora_affinity.go
index 8052479..ab4fd98 100644
--- a/pkg/epp/scheduling/framework/plugins/scorer/lora_affinity.go
+++ b/pkg/epp/scheduling/framework/plugins/scorer/lora_affinity.go
@@ -41,18 +41,18 @@ func LoraAffinityScorerFactory(name string, _ json.RawMessage, _ plugins.Handle)
 // NewLoraAffinityScorer initializes a new LoraAffinityScorer and returns its pointer.
 func NewLoraAffinityScorer() *LoraAffinityScorer {
 	return &LoraAffinityScorer{
-		tn: plugins.TypedName{Type: LoraAffinityScorerType, Name: LoraAffinityScorerType},
+		typedName: plugins.TypedName{Type: LoraAffinityScorerType, Name: LoraAffinityScorerType},
 	}
 }
 
 // LoraAffinityScorer scores list of candidate pods based on Lora affinity and availability.
 type LoraAffinityScorer struct {
-	tn plugins.TypedName
+	typedName plugins.TypedName
 }
 
 // TypedName returns the type and name tuple of this plugin instance.
 func (s *LoraAffinityScorer) TypedName() plugins.TypedName {
-	return s.tn
+	return s.typedName
 }
 
 // Consumes returns the list of data that is consumed by the plugin.
@@ -65,7 +65,7 @@ func (s *LoraAffinityScorer) Consumes() map[string]any {
 
 // WithName sets the name of the scorer.
 func (s *LoraAffinityScorer) WithName(name string) *LoraAffinityScorer {
-	s.tn.Name = name
+	s.typedName.Name = name
 	return s
 }
 



Test patch:
diff --git a/pkg/epp/requestcontrol/director_test.go b/pkg/epp/requestcontrol/director_test.go
index 9266897..b48067a 100644
--- a/pkg/epp/requestcontrol/director_test.go
+++ b/pkg/epp/requestcontrol/director_test.go
@@ -141,19 +141,19 @@ func newMockPrepareDataPlugin(name string) *mockPrepareDataPlugin {
 }
 
 type mockAdmissionPlugin struct {
-	tn          plugins.TypedName
+	typedName   plugins.TypedName
 	denialError error
 }
 
 func newMockAdmissionPlugin(name string, denialError error) *mockAdmissionPlugin {
 	return &mockAdmissionPlugin{
-		tn:          plugins.TypedName{Type: "mock-admit-data", Name: name},
+		typedName:   plugins.TypedName{Type: "mock-admit-data", Name: name},
 		denialError: denialError,
 	}
 }
 
 func (m *mockAdmissionPlugin) TypedName() plugins.TypedName {
-	return m.tn
+	return m.typedName
 }
 
 func (m *mockAdmissionPlugin) AdmitRequest(ctx context.Context, request *schedulingtypes.LLMRequest, pods []schedulingtypes.Pod) error {
@@ -1238,51 +1238,51 @@ const (
 )
 
 type testResponseReceived struct {
-	tn                      plugins.TypedName
+	typedName               plugins.TypedName
 	lastRespOnResponse      *Response
 	lastTargetPodOnResponse string
 }
 
 type testResponseStreaming struct {
-	tn                       plugins.TypedName
+	typedName                plugins.TypedName
 	lastRespOnStreaming      *Response
 	lastTargetPodOnStreaming string
 }
 
 type testResponseComplete struct {
-	tn                      plugins.TypedName
+	typedName               plugins.TypedName
 	lastRespOnComplete      *Response
 	lastTargetPodOnComplete string
 }
 
 func newTestResponseReceived(name string) *testResponseReceived {
 	return &testResponseReceived{
-		tn: plugins.TypedName{Type: testResponseReceivedType, Name: name},
+		typedName: plugins.TypedName{Type: testResponseReceivedType, Name: name},
 	}
 }
 
 func newTestResponseStreaming(name string) *testResponseStreaming {
 	return &testResponseStreaming{
-		tn: plugins.TypedName{Type: testPostStreamingType, Name: name},
+		typedName: plugins.TypedName{Type: testPostStreamingType, Name: name},
 	}
 }
 
 func newTestResponseComplete(name string) *testResponseComplete {
 	return &testResponseComplete{
-		tn: plugins.TypedName{Type: testPostCompleteType, Name: name},
+		typedName: plugins.TypedName{Type: testPostCompleteType, Name: name},
 	}
 }
 
 func (p *testResponseReceived) TypedName() plugins.TypedName {
-	return p.tn
+	return p.typedName
 }
 
 func (p *testResponseStreaming) TypedName() plugins.TypedName {
-	return p.tn
+	return p.typedName
 }
 
 func (p *testResponseComplete) TypedName() plugins.TypedName {
-	return p.tn
+	return p.typedName
 }
 
 func (p *testResponseReceived) ResponseReceived(_ context.Context, _ *schedulingtypes.LLMRequest, response *Response, targetPod *backend.Pod) {