github.com/kubewharf/katalyst-core@v0.5.3/pkg/agent/resourcemanager/fetcher/kubelet/topology/interface.go (about)

     1  /*
     2  Copyright 2022 The Katalyst 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 topology
    18  
    19  import (
    20  	"context"
    21  
    22  	nodev1alpha1 "github.com/kubewharf/katalyst-api/pkg/apis/node/v1alpha1"
    23  )
    24  
    25  // Adapter is to get topology zone status, the src of that can be pod resource api
    26  // or kubelet checkpoint.
    27  type Adapter interface {
    28  	// GetTopologyZones return newest topology zone status
    29  	GetTopologyZones(ctx context.Context) ([]*nodev1alpha1.TopologyZone, error)
    30  
    31  	// GetTopologyPolicy return newest topology policy status
    32  	GetTopologyPolicy(ctx context.Context) (nodev1alpha1.TopologyPolicy, error)
    33  
    34  	// Run is to start the topology adapter to watch the topology change
    35  	Run(ctx context.Context, handler func()) error
    36  }
    37  
    38  // DummyAdapter is a dummy topology adapter for test
    39  type DummyAdapter struct{}
    40  
    41  var _ Adapter = DummyAdapter{}
    42  
    43  // GetTopologyZones is to get dummy topology zone status
    44  func (d DummyAdapter) GetTopologyZones(_ context.Context) ([]*nodev1alpha1.TopologyZone, error) {
    45  	return []*nodev1alpha1.TopologyZone{}, nil
    46  }
    47  
    48  // GetTopologyPolicy is to get dummy topology policy status
    49  func (d DummyAdapter) GetTopologyPolicy(_ context.Context) (nodev1alpha1.TopologyPolicy, error) {
    50  	dummyTopologyPolicy := nodev1alpha1.TopologyPolicy("")
    51  	return dummyTopologyPolicy, nil
    52  }
    53  
    54  // Run is to start the dummy topology adapter
    55  func (d DummyAdapter) Run(_ context.Context, _ func()) error {
    56  	return nil
    57  }