Skip to content

Commit 19db87d

Browse files
committed
converged to a single plugins interface based on code review
Signed-off-by: Nir Rozenbaum <[email protected]>
1 parent d9ab99b commit 19db87d

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

pkg/epp/plugins/plugins.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package plugins
18+
19+
// Plugin defines the interface for a plugin.
20+
// This interface should be embedded in all plugins across the code.
21+
type Plugin interface {
22+
// Name returns the name of the plugin.
23+
Name() string
24+
}

pkg/epp/requestcontrol/plugins.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,17 @@ import (
2020
"context"
2121

2222
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/backend"
23+
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/plugins"
2324
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/types"
2425
)
2526

2627
const (
2728
PostResponsePluginType = "PostResponse"
2829
)
2930

30-
// Plugin defines the interface for requestcontrol plugins.
31-
type Plugin interface {
32-
// Name returns the name of the plugin.
33-
Name() string
34-
}
35-
3631
// PostResponse is called by the director after a successful response was sent.
3732
// The given pod argument is the pod that served the request.
3833
type PostResponsePlugin interface {
39-
Plugin
34+
plugins.Plugin
4035
PostResponse(ctx context.Context, request *types.LLMRequest, response *Response, targetPod *backend.Pod)
4136
}

pkg/epp/scheduling/framework/plugins.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package framework
1919
import (
2020
"context"
2121

22+
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/plugins"
2223
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/types"
2324
)
2425

@@ -30,41 +31,34 @@ const (
3031
PostCyclePluginType = "PostCycle"
3132
)
3233

33-
// Plugin defines the interface for scheduler plugins, combining scoring, filtering,
34-
// and event handling capabilities.
35-
type Plugin interface {
36-
// Name returns the name of the plugin.
37-
Name() string
38-
}
39-
4034
// ProfilePicker selects the SchedulingProfiles to run from a list of candidate profiles, while taking into consideration the request properties
4135
// and the previously executed SchedluderProfile cycles along with their results.
4236
type ProfilePicker interface {
43-
Plugin
37+
plugins.Plugin
4438
Pick(request *types.LLMRequest, profiles map[string]*SchedulerProfile, executionResults map[string]*types.Result) map[string]*SchedulerProfile
4539
}
4640

4741
// Filter defines the interface for filtering a list of pods based on context.
4842
type Filter interface {
49-
Plugin
43+
plugins.Plugin
5044
Filter(ctx context.Context, request *types.LLMRequest, cycleState *types.CycleState, pods []types.Pod) []types.Pod
5145
}
5246

5347
// Scorer defines the interface for scoring a list of pods based on context.
5448
// Scorers must score pods with a value within the range of [0,1] where 1 is the highest score.
5549
type Scorer interface {
56-
Plugin
50+
plugins.Plugin
5751
Score(ctx context.Context, request *types.LLMRequest, cycleState *types.CycleState, pods []types.Pod) map[types.Pod]float64
5852
}
5953

6054
// Picker picks the final pod(s) to send the request to.
6155
type Picker interface {
62-
Plugin
56+
plugins.Plugin
6357
Pick(ctx context.Context, cycleState *types.CycleState, scoredPods []*types.ScoredPod) *types.Result
6458
}
6559

6660
// PostCycle is called by the scheduler after it selects a targetPod for the request in the SchedulerProfile cycle.
6761
type PostCycle interface {
68-
Plugin
62+
plugins.Plugin
6963
PostCycle(ctx context.Context, cycleState *types.CycleState, res *types.Result)
7064
}

pkg/epp/scheduling/framework/scheduler_profile.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"sigs.k8s.io/controller-runtime/pkg/log"
2525
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/metrics"
26+
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/plugins"
2627
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/types"
2728
errutil "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/util/error"
2829
logutil "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/util/logging"
@@ -79,7 +80,7 @@ func (p *SchedulerProfile) WithPostCyclePlugins(plugins ...PostCycle) *Scheduler
7980
// Special Case: In order to add a scorer, one must use the scorer.NewWeightedScorer function in order to provide a weight.
8081
// if a scorer implements more than one interface, supplying a WeightedScorer is sufficient. The function will take the internal
8182
// scorer object and register it to all interfaces it implements.
82-
func (p *SchedulerProfile) AddPlugins(pluginObjects ...Plugin) error {
83+
func (p *SchedulerProfile) AddPlugins(pluginObjects ...plugins.Plugin) error {
8384
for _, plugin := range pluginObjects {
8485
if weightedScorer, ok := plugin.(*WeightedScorer); ok {
8586
p.scorers = append(p.scorers, weightedScorer)

0 commit comments

Comments
 (0)