Skip to content

Commit 7ad8bab

Browse files
committed
Standardize plugins.TypedName field name from 'tn' to 'typedName'
- Change LoraAffinityScorer to use typedName - Change SLOAwareRouter to use typedName - Update test mocks: mockAdmissionPlugin, testResponseReceived, testResponseStreaming, testResponseComplete, mockDataSource - Improves consistency across all plugin implementations
1 parent d886b15 commit 7ad8bab

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

pkg/epp/datalayer/datasource_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ const (
3131
)
3232

3333
type mockDataSource struct {
34-
tn plugins.TypedName
34+
typedName plugins.TypedName
3535
}
3636

37-
func (m *mockDataSource) TypedName() plugins.TypedName { return m.tn }
37+
func (m *mockDataSource) TypedName() plugins.TypedName { return m.typedName }
3838
func (m *mockDataSource) Extractors() []string { return []string{} }
3939
func (m *mockDataSource) AddExtractor(_ Extractor) error { return nil }
4040
func (m *mockDataSource) Collect(_ context.Context, _ Endpoint) error { return nil }
4141

4242
func TestRegisterAndGetSource(t *testing.T) {
4343
reg := DataSourceRegistry{}
44-
ds := &mockDataSource{tn: plugins.TypedName{Type: testType, Name: testType}}
44+
ds := &mockDataSource{typedName: plugins.TypedName{Type: testType, Name: testType}}
4545

4646
err := reg.Register(ds)
4747
assert.NoError(t, err, "expected no error on first registration")

pkg/epp/requestcontrol/director_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,19 @@ func newMockPrepareDataPlugin(name string) *mockPrepareDataPlugin {
141141
}
142142

143143
type mockAdmissionPlugin struct {
144-
tn plugins.TypedName
144+
typedName plugins.TypedName
145145
denialError error
146146
}
147147

148148
func newMockAdmissionPlugin(name string, denialError error) *mockAdmissionPlugin {
149149
return &mockAdmissionPlugin{
150-
tn: plugins.TypedName{Type: "mock-admit-data", Name: name},
150+
typedName: plugins.TypedName{Type: "mock-admit-data", Name: name},
151151
denialError: denialError,
152152
}
153153
}
154154

155155
func (m *mockAdmissionPlugin) TypedName() plugins.TypedName {
156-
return m.tn
156+
return m.typedName
157157
}
158158

159159
func (m *mockAdmissionPlugin) AdmitRequest(ctx context.Context, request *schedulingtypes.LLMRequest, pods []schedulingtypes.Pod) error {
@@ -1238,51 +1238,51 @@ const (
12381238
)
12391239

12401240
type testResponseReceived struct {
1241-
tn plugins.TypedName
1241+
typedName plugins.TypedName
12421242
lastRespOnResponse *Response
12431243
lastTargetPodOnResponse string
12441244
}
12451245

12461246
type testResponseStreaming struct {
1247-
tn plugins.TypedName
1247+
typedName plugins.TypedName
12481248
lastRespOnStreaming *Response
12491249
lastTargetPodOnStreaming string
12501250
}
12511251

12521252
type testResponseComplete struct {
1253-
tn plugins.TypedName
1253+
typedName plugins.TypedName
12541254
lastRespOnComplete *Response
12551255
lastTargetPodOnComplete string
12561256
}
12571257

12581258
func newTestResponseReceived(name string) *testResponseReceived {
12591259
return &testResponseReceived{
1260-
tn: plugins.TypedName{Type: testResponseReceivedType, Name: name},
1260+
typedName: plugins.TypedName{Type: testResponseReceivedType, Name: name},
12611261
}
12621262
}
12631263

12641264
func newTestResponseStreaming(name string) *testResponseStreaming {
12651265
return &testResponseStreaming{
1266-
tn: plugins.TypedName{Type: testPostStreamingType, Name: name},
1266+
typedName: plugins.TypedName{Type: testPostStreamingType, Name: name},
12671267
}
12681268
}
12691269

12701270
func newTestResponseComplete(name string) *testResponseComplete {
12711271
return &testResponseComplete{
1272-
tn: plugins.TypedName{Type: testPostCompleteType, Name: name},
1272+
typedName: plugins.TypedName{Type: testPostCompleteType, Name: name},
12731273
}
12741274
}
12751275

12761276
func (p *testResponseReceived) TypedName() plugins.TypedName {
1277-
return p.tn
1277+
return p.typedName
12781278
}
12791279

12801280
func (p *testResponseStreaming) TypedName() plugins.TypedName {
1281-
return p.tn
1281+
return p.typedName
12821282
}
12831283

12841284
func (p *testResponseComplete) TypedName() plugins.TypedName {
1285-
return p.tn
1285+
return p.typedName
12861286
}
12871287

12881288
func (p *testResponseReceived) ResponseReceived(_ context.Context, _ *schedulingtypes.LLMRequest, response *Response, targetPod *backend.Pod) {

pkg/epp/scheduling/framework/plugins/multi/slo_aware_router/scorer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
)
3838

3939
type SLOAwareRouter struct {
40-
tn plugins.TypedName
40+
typedName plugins.TypedName
4141
latencypredictor latencypredictor.PredictorInterface
4242
runningRequestLists map[types.NamespacedName]*requestPriorityQueue
4343
sloContextStore sync.Map // map[string]*SLORequestContext
@@ -108,7 +108,7 @@ func NewSLOAwareRouter(config Config, predictor latencypredictor.PredictorInterf
108108
}
109109

110110
return &SLOAwareRouter{
111-
tn: plugins.TypedName{Type: SLOAwareRouterPluginType, Name: SLOAwareRouterPluginType},
111+
typedName: plugins.TypedName{Type: SLOAwareRouterPluginType, Name: SLOAwareRouterPluginType},
112112
latencypredictor: predictor,
113113
runningRequestLists: make(map[types.NamespacedName]*requestPriorityQueue),
114114
sloContextStore: sync.Map{},
@@ -132,11 +132,11 @@ func startPredictor(handle plugins.Handle) (latencypredictor.PredictorInterface,
132132
}
133133

134134
func (s *SLOAwareRouter) TypedName() plugins.TypedName {
135-
return s.tn
135+
return s.typedName
136136
}
137137

138138
func (s *SLOAwareRouter) WithName(name string) *SLOAwareRouter {
139-
s.tn.Name = name
139+
s.typedName.Name = name
140140
return s
141141
}
142142

pkg/epp/scheduling/framework/plugins/scorer/lora_affinity.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ func LoraAffinityScorerFactory(name string, _ json.RawMessage, _ plugins.Handle)
4141
// NewLoraAffinityScorer initializes a new LoraAffinityScorer and returns its pointer.
4242
func NewLoraAffinityScorer() *LoraAffinityScorer {
4343
return &LoraAffinityScorer{
44-
tn: plugins.TypedName{Type: LoraAffinityScorerType, Name: LoraAffinityScorerType},
44+
typedName: plugins.TypedName{Type: LoraAffinityScorerType, Name: LoraAffinityScorerType},
4545
}
4646
}
4747

4848
// LoraAffinityScorer scores list of candidate pods based on Lora affinity and availability.
4949
type LoraAffinityScorer struct {
50-
tn plugins.TypedName
50+
typedName plugins.TypedName
5151
}
5252

5353
// TypedName returns the type and name tuple of this plugin instance.
5454
func (s *LoraAffinityScorer) TypedName() plugins.TypedName {
55-
return s.tn
55+
return s.typedName
5656
}
5757

5858
// Consumes returns the list of data that is consumed by the plugin.
@@ -65,7 +65,7 @@ func (s *LoraAffinityScorer) Consumes() map[string]any {
6565

6666
// WithName sets the name of the scorer.
6767
func (s *LoraAffinityScorer) WithName(name string) *LoraAffinityScorer {
68-
s.tn.Name = name
68+
s.typedName.Name = name
6969
return s
7070
}
7171

0 commit comments

Comments
 (0)