Skip to content

Commit 5d4d3ec

Browse files
authored
refactor: plugin.Name() => plugin. Type() (#1038)
Signed-off-by: Etai Lev Ran <[email protected]>
1 parent 3810963 commit 5d4d3ec

File tree

23 files changed

+124
-124
lines changed

23 files changed

+124
-124
lines changed

cmd/epp/runner/register.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ import (
2727

2828
// RegisterAllPlugins registers the factory functions of all known plugins
2929
func RegisterAllPlugins() {
30-
plugins.Register(filter.LeastKVCacheFilterName, filter.LeastKVCacheFilterFactory)
31-
plugins.Register(filter.LeastQueueFilterName, filter.LeastQueueFilterFactory)
32-
plugins.Register(filter.LoraAffinityFilterName, filter.LoraAffinityFilterFactory)
33-
plugins.Register(filter.LowQueueFilterName, filter.LowQueueFilterFactory)
34-
plugins.Register(prefix.PrefixCachePluginName, prefix.PrefixCachePluginFactory)
35-
plugins.Register(picker.MaxScorePickerName, picker.MaxScorePickerFactory)
36-
plugins.Register(picker.RandomPickerName, picker.RandomPickerFactory)
37-
plugins.Register(profile.SingleProfileHandlerName, profile.SingleProfileHandlerFactory)
38-
plugins.Register(scorer.KvCacheScorerName, scorer.KvCacheScorerFactory)
39-
plugins.Register(scorer.QueueScorerName, scorer.QueueScorerFactory)
30+
plugins.Register(filter.LeastKVCacheFilterType, filter.LeastKVCacheFilterFactory)
31+
plugins.Register(filter.LeastQueueFilterType, filter.LeastQueueFilterFactory)
32+
plugins.Register(filter.LoraAffinityFilterType, filter.LoraAffinityFilterFactory)
33+
plugins.Register(filter.LowQueueFilterType, filter.LowQueueFilterFactory)
34+
plugins.Register(prefix.PrefixCachePluginType, prefix.PrefixCachePluginFactory)
35+
plugins.Register(picker.MaxScorePickerType, picker.MaxScorePickerFactory)
36+
plugins.Register(picker.RandomPickerType, picker.RandomPickerFactory)
37+
plugins.Register(profile.SingleProfileHandlerType, profile.SingleProfileHandlerFactory)
38+
plugins.Register(scorer.KvCacheScorerType, scorer.KvCacheScorerFactory)
39+
plugins.Register(scorer.QueueScorerType, scorer.QueueScorerFactory)
4040
}
4141

4242
// eppHandle is a temporary implementation of the interface plugins.Handle

conformance/testing-epp/plugins/filter/request_header_based_filter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ func NewHeaderBasedTestingFilter() *HeaderBasedTestingFilter {
4444
// HeaderBasedTestingFilter filters Pods based on an address specified in the "test-epp-endpoint-selection" request header.
4545
type HeaderBasedTestingFilter struct{}
4646

47-
// Name returns the name of the filter.
48-
func (f *HeaderBasedTestingFilter) Name() string {
47+
// Type returns the type of the filter.
48+
func (f *HeaderBasedTestingFilter) Type() string {
4949
return "header-based-testing"
5050
}
5151

docs/proposals/0845-scheduler-architecture-proposal/interfaces/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ type SchedulingResult struct {
8585

8686
// Plugin is the parent type for all the scheduling framework plugins.
8787
type Plugin interface {
88-
Name() string
88+
Type() string
8989
}
9090

9191
// ProfileHandler defines the interface for handling multi SchedulerProfile instances.

pkg/epp/common/config/configloader_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ import (
3131
)
3232

3333
const (
34-
testProfileHandlerName = "test-profile-handler"
35-
test1Name = "test-one"
36-
test2Name = "test-two"
37-
testPickerName = "test-picker"
34+
testProfileHandlerType = "test-profile-handler"
35+
test1Type = "test-one"
36+
test2Type = "test-two"
37+
testPickerType = "test-picker"
3838
)
3939

4040
func TestLoadConfiguration(t *testing.T) {
@@ -50,21 +50,21 @@ func TestLoadConfiguration(t *testing.T) {
5050
Plugins: []configapi.PluginSpec{
5151
{
5252
Name: "test1",
53-
PluginName: test1Name,
53+
PluginName: test1Type,
5454
Parameters: json.RawMessage("{\"threshold\":10}"),
5555
},
5656
{
5757
Name: "profileHandler",
5858
PluginName: "test-profile-handler",
5959
},
6060
{
61-
Name: test2Name,
62-
PluginName: test2Name,
61+
Name: test2Type,
62+
PluginName: test2Type,
6363
Parameters: json.RawMessage("{\"hashBlockSize\":32}"),
6464
},
6565
{
6666
Name: "testPicker",
67-
PluginName: testPickerName,
67+
PluginName: testPickerType,
6868
},
6969
},
7070
SchedulingProfiles: []configapi.SchedulingProfile{
@@ -463,8 +463,8 @@ type test1 struct {
463463
Threshold int `json:"threshold"`
464464
}
465465

466-
func (f *test1) Name() string {
467-
return test1Name
466+
func (f *test1) Type() string {
467+
return test1Type
468468
}
469469

470470
// Filter filters out pods that doesn't meet the filter criteria.
@@ -478,8 +478,8 @@ var _ framework.PostCycle = &test2{}
478478

479479
type test2 struct{}
480480

481-
func (f *test2) Name() string {
482-
return test2Name
481+
func (f *test2) Type() string {
482+
return test2Type
483483
}
484484

485485
func (m *test2) Score(ctx context.Context, request *types.LLMRequest, cycleState *types.CycleState, pods []types.Pod) map[types.Pod]float64 {
@@ -494,8 +494,8 @@ var _ framework.Picker = &testPicker{}
494494

495495
type testPicker struct{}
496496

497-
func (p *testPicker) Name() string {
498-
return testPickerName
497+
func (p *testPicker) Type() string {
498+
return testPickerType
499499
}
500500

501501
func (p *testPicker) Pick(ctx context.Context, cycleState *types.CycleState, scoredPods []*types.ScoredPod) *types.ProfileRunResult {
@@ -507,8 +507,8 @@ var _ framework.ProfileHandler = &testProfileHandler{}
507507

508508
type testProfileHandler struct{}
509509

510-
func (p *testProfileHandler) Name() string {
511-
return testProfileHandlerName
510+
func (p *testProfileHandler) Type() string {
511+
return testProfileHandlerType
512512
}
513513

514514
func (p *testProfileHandler) Pick(ctx context.Context, request *types.LLMRequest, profiles map[string]*framework.SchedulerProfile, executionResults map[string]*types.ProfileRunResult) map[string]*framework.SchedulerProfile {
@@ -520,27 +520,27 @@ func (p *testProfileHandler) ProcessResults(ctx context.Context, request *types.
520520
}
521521

522522
func registerTestPlugins() {
523-
plugins.Register(test1Name,
523+
plugins.Register(test1Type,
524524
func(name string, parameters json.RawMessage, handle plugins.Handle) (plugins.Plugin, error) {
525525
result := test1{}
526526
err := json.Unmarshal(parameters, &result)
527527
return &result, err
528528
},
529529
)
530530

531-
plugins.Register(test2Name,
531+
plugins.Register(test2Type,
532532
func(name string, parameters json.RawMessage, handle plugins.Handle) (plugins.Plugin, error) {
533533
return &test2{}, nil
534534
},
535535
)
536536

537-
plugins.Register(testPickerName,
537+
plugins.Register(testPickerType,
538538
func(name string, parameters json.RawMessage, handle plugins.Handle) (plugins.Plugin, error) {
539539
return &testPicker{}, nil
540540
},
541541
)
542542

543-
plugins.Register(testProfileHandlerName,
543+
plugins.Register(testProfileHandlerType,
544544
func(name string, parameters json.RawMessage, handle plugins.Handle) (plugins.Plugin, error) {
545545
return &testProfileHandler{}, nil
546546
},

pkg/epp/plugins/plugins.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ package plugins
1919
// Plugin defines the interface for a plugin.
2020
// This interface should be embedded in all plugins across the code.
2121
type Plugin interface {
22-
// Name returns the name of the plugin.
23-
Name() string
22+
// Type returns the type of the plugin.
23+
Type() string
2424
}
2525

2626
// Handle provides plugins set of standard data and tools to work with

pkg/epp/requestcontrol/director.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,18 @@ func RandomWeightedDraw(logger logr.Logger, model *v1alpha2.InferenceModel, seed
254254
func (d *Director) runPreRequestPlugins(ctx context.Context, request *schedulingtypes.LLMRequest, schedulingResult *schedulingtypes.SchedulingResult,
255255
targetPort int) {
256256
for _, plugin := range d.preRequestPlugins {
257-
log.FromContext(ctx).V(logutil.DEBUG).Info("Running pre-request plugin", "plugin", plugin.Name())
257+
log.FromContext(ctx).V(logutil.DEBUG).Info("Running pre-request plugin", "plugin", plugin.Type())
258258
before := time.Now()
259259
plugin.PreRequest(ctx, request, schedulingResult, targetPort)
260-
metrics.RecordRequestControlPluginProcessingLatency(PreRequestPluginType, plugin.Name(), time.Since(before))
260+
metrics.RecordRequestControlPluginProcessingLatency(PreRequestPluginType, plugin.Type(), time.Since(before))
261261
}
262262
}
263263

264264
func (d *Director) runPostResponsePlugins(ctx context.Context, request *schedulingtypes.LLMRequest, response *Response, targetPod *backend.Pod) {
265265
for _, plugin := range d.postResponsePlugins {
266-
log.FromContext(ctx).V(logutil.DEBUG).Info("Running post-response plugin", "plugin", plugin.Name())
266+
log.FromContext(ctx).V(logutil.DEBUG).Info("Running post-response plugin", "plugin", plugin.Type())
267267
before := time.Now()
268268
plugin.PostResponse(ctx, request, response, targetPod)
269-
metrics.RecordRequestControlPluginProcessingLatency(PostResponsePluginType, plugin.Name(), time.Since(before))
269+
metrics.RecordRequestControlPluginProcessingLatency(PostResponsePluginType, plugin.Type(), time.Since(before))
270270
}
271271
}

pkg/epp/requestcontrol/director_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ func pointer(v int32) *int32 {
521521

522522
func TestDirector_HandleResponse(t *testing.T) {
523523
pr1 := &testPostResponse{
524-
NameRes: "pr1",
524+
TypeRes: "pr1",
525525
}
526526

527527
ctx := logutil.NewTestLoggerIntoContext(context.Background())
@@ -559,12 +559,12 @@ func TestDirector_HandleResponse(t *testing.T) {
559559
}
560560

561561
type testPostResponse struct {
562-
NameRes string
562+
TypeRes string
563563
lastRespOnResponse *Response
564564
lastTargetPodOnResponse string
565565
}
566566

567-
func (p *testPostResponse) Name() string { return p.NameRes }
567+
func (p *testPostResponse) Type() string { return p.TypeRes }
568568

569569
func (p *testPostResponse) PostResponse(_ context.Context, _ *schedulingtypes.LLMRequest, response *Response, targetPod *backend.Pod) {
570570
p.lastRespOnResponse = response

pkg/epp/scheduling/framework/plugins/filter/decision_tree_filter.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ type DecisionTreeFilter struct {
4747
NextOnSuccessOrFailure framework.Filter
4848
}
4949

50-
// Name returns the name of the filter.
51-
func (f *DecisionTreeFilter) Name() string {
50+
// Type returns the type of the filter.
51+
func (f *DecisionTreeFilter) Type() string {
5252
if f == nil {
5353
return "nil"
5454
}
55-
return f.Current.Name()
55+
return f.Current.Type()
5656
}
5757

5858
// Filter filters out pods that doesn't meet the filter criteria.
@@ -69,7 +69,7 @@ func (f *DecisionTreeFilter) Filter(ctx context.Context, request *types.LLMReque
6969
if f.NextOnSuccess != nil {
7070
next = f.NextOnSuccess
7171
}
72-
loggerTrace.Info("Filter succeeded", "filter", f.Name(), "next", next.Name(), "filteredPodCount", len(filteredPod))
72+
loggerTrace.Info("Filter succeeded", "filter", f.Type(), "next", next.Type(), "filteredPodCount", len(filteredPod))
7373
// On success, pass the filtered result to the next filter.
7474
return next.Filter(ctx, request, cycleState, filteredPod)
7575
} else {
@@ -80,7 +80,7 @@ func (f *DecisionTreeFilter) Filter(ctx context.Context, request *types.LLMReque
8080
if f.NextOnFailure != nil {
8181
next = f.NextOnFailure
8282
}
83-
loggerTrace.Info("Filter failed", "filter", f.Name(), "next", next.Name())
83+
loggerTrace.Info("Filter failed", "filter", f.Type(), "next", next.Type())
8484
// On failure, pass the initial set of pods to the next filter.
8585
return next.Filter(ctx, request, cycleState, pods)
8686
}

pkg/epp/scheduling/framework/plugins/filter/filter_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ var _ framework.Filter = &filterAll{}
3535

3636
type filterAll struct{}
3737

38-
func (f *filterAll) Name() string {
39-
return "filter all"
38+
func (f *filterAll) Type() string {
39+
return "filter-all"
4040
}
4141

4242
func (f *filterAll) Filter(_ context.Context, _ *types.LLMRequest, _ *types.CycleState, pods []types.Pod) []types.Pod {

pkg/epp/scheduling/framework/plugins/filter/least_kvcache_filter.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
)
2828

2929
const (
30-
LeastKVCacheFilterName = "least-KV-cache"
30+
LeastKVCacheFilterType = "least-KV-cache"
3131
)
3232

3333
// compile-time type validation
@@ -50,9 +50,9 @@ func NewLeastKVCacheFilter() *LeastKVCacheFilter {
5050
// least one as it gives more choices for the next filter, which on aggregate gave better results.
5151
type LeastKVCacheFilter struct{}
5252

53-
// Name returns the name of the filter.
54-
func (f *LeastKVCacheFilter) Name() string {
55-
return LeastKVCacheFilterName
53+
// Type returns the type of the filter.
54+
func (f *LeastKVCacheFilter) Type() string {
55+
return LeastKVCacheFilterType
5656
}
5757

5858
// Filter filters out pods that doesn't meet the filter criteria.

0 commit comments

Comments
 (0)