Skip to content

Commit

Permalink
tidy code
Browse files Browse the repository at this point in the history
Signed-off-by: Kuromesi <[email protected]>
  • Loading branch information
Kuromesi committed Jan 14, 2025
1 parent 24e7d3b commit d7edec8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/ext-proc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func startExternalProcessorServer(
) *grpc.Server {
svr := grpc.NewServer()

var orchestrator *scheduling.FilterOrchestratorImpl
var orchestrator scheduling.FilterOrchestrator
if *enableFilterConfiguration {
orchestrator = scheduling.NewFilterOrchestrator(datastore)
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/ext-proc/scheduling/orchestrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ func NewFilterOrchestrator(datastore *backend.K8sDatastore) *FilterOrchestratorI
}
}

func NewDefaultFilterOrchestrator() *DefaultFilterOrchestrator {
return &DefaultFilterOrchestrator{}
}

// DefaultFilterOrchestrator is a filter orchestrator that returns the default filter chain
type DefaultFilterOrchestrator struct{}

var _ FilterOrchestrator = &DefaultFilterOrchestrator{}

func (DefaultFilterOrchestrator) Orchestrate() FilterChain {
return defaultFilter
}

// FilterOrchestratorImpl is a filter orchestrator that reads the filter configuration
// from configmap and orchestrate the filter chain
type FilterOrchestratorImpl struct {
datastore *backend.K8sDatastore
lastUpdated string
Expand Down
6 changes: 4 additions & 2 deletions pkg/ext-proc/scheduling/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func NewScheduler(pmp PodMetricsProvider, opts ...SchedulerOption) *Scheduler {
s := &Scheduler{
podMetricsProvider: pmp,
filter: defaultFilter,
filterOrchestrator: &FilterOrchestratorImpl{},
filterOrchestrator: NewDefaultFilterOrchestrator(),
}

for _, opt := range opts {
Expand All @@ -105,7 +105,9 @@ func NewScheduler(pmp PodMetricsProvider, opts ...SchedulerOption) *Scheduler {

func WithOrchestrator(orchestrator FilterOrchestrator) SchedulerOption {
return func(s *Scheduler) {
s.filterOrchestrator = orchestrator
if orchestrator != nil {
s.filterOrchestrator = orchestrator
}
}
}

Expand Down

0 comments on commit d7edec8

Please sign in to comment.