Skip to content

Commit ae67b79

Browse files
elevranshmuelk
authored andcommitted
refactor: plugin.Name() => plugin. Type() (kubernetes-sigs#1038)
Signed-off-by: Etai Lev Ran <elevran@gmail.com>
1 parent 0e93aa8 commit ae67b79

File tree

22 files changed

+119
-119
lines changed

22 files changed

+119
-119
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 an 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/loader/configloader_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ import (
3636
)
3737

3838
const (
39-
testProfileHandlerName = "test-profile-handler"
40-
test1Name = "test-one"
41-
test2Name = "test-two"
42-
testPickerName = "test-picker"
39+
testProfileHandlerType = "test-profile-handler"
40+
test1Type = "test-one"
41+
test2Type = "test-two"
42+
testPickerType = "test-picker"
4343
)
4444

4545
func TestLoadConfiguration(t *testing.T) {
@@ -55,21 +55,21 @@ func TestLoadConfiguration(t *testing.T) {
5555
Plugins: []configapi.PluginSpec{
5656
{
5757
Name: "test1",
58-
PluginName: test1Name,
58+
PluginName: test1Type,
5959
Parameters: json.RawMessage("{\"threshold\":10}"),
6060
},
6161
{
6262
Name: "profileHandler",
6363
PluginName: "test-profile-handler",
6464
},
6565
{
66-
Name: test2Name,
67-
PluginName: test2Name,
66+
Name: test2Type,
67+
PluginName: test2Type,
6868
Parameters: json.RawMessage("{\"hashBlockSize\":32}"),
6969
},
7070
{
7171
Name: "testPicker",
72-
PluginName: testPickerName,
72+
PluginName: testPickerType,
7373
},
7474
},
7575
SchedulingProfiles: []configapi.SchedulingProfile{
@@ -552,8 +552,8 @@ type test1 struct {
552552
Threshold int `json:"threshold"`
553553
}
554554

555-
func (f *test1) Name() string {
556-
return test1Name
555+
func (f *test1) Type() string {
556+
return test1Type
557557
}
558558

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

568568
type test2 struct{}
569569

570-
func (f *test2) Name() string {
571-
return test2Name
570+
func (f *test2) Type() string {
571+
return test2Type
572572
}
573573

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

584584
type testPicker struct{}
585585

586-
func (p *testPicker) Name() string {
587-
return testPickerName
586+
func (p *testPicker) Type() string {
587+
return testPickerType
588588
}
589589

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

597597
type testProfileHandler struct{}
598598

599-
func (p *testProfileHandler) Name() string {
600-
return testProfileHandlerName
599+
func (p *testProfileHandler) Type() string {
600+
return testProfileHandlerType
601601
}
602602

603603
func (p *testProfileHandler) Pick(ctx context.Context, request *types.LLMRequest, profiles map[string]*framework.SchedulerProfile, executionResults map[string]*types.ProfileRunResult) map[string]*framework.SchedulerProfile {
@@ -609,27 +609,27 @@ func (p *testProfileHandler) ProcessResults(ctx context.Context, request *types.
609609
}
610610

611611
func registerTestPlugins() {
612-
plugins.Register(test1Name,
612+
plugins.Register(test1Type,
613613
func(name string, parameters json.RawMessage, handle plugins.Handle) (plugins.Plugin, error) {
614614
result := test1{}
615615
err := json.Unmarshal(parameters, &result)
616616
return &result, err
617617
},
618618
)
619619

620-
plugins.Register(test2Name,
620+
plugins.Register(test2Type,
621621
func(name string, parameters json.RawMessage, handle plugins.Handle) (plugins.Plugin, error) {
622622
return &test2{}, nil
623623
},
624624
)
625625

626-
plugins.Register(testPickerName,
626+
plugins.Register(testPickerType,
627627
func(name string, parameters json.RawMessage, handle plugins.Handle) (plugins.Plugin, error) {
628628
return &testPicker{}, nil
629629
},
630630
)
631631

632-
plugins.Register(testProfileHandlerName,
632+
plugins.Register(testProfileHandlerType,
633633
func(name string, parameters json.RawMessage, handle plugins.Handle) (plugins.Plugin, error) {
634634
return &testProfileHandler{}, nil
635635
},

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)