predictor_source

package
v0.11.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EVENT_UPDATE = iota
	EVENT_DELETE
)
View Source
const ERR_TOO_OLD = Error("ERR_TOO_OLD")

Variables

This section is empty.

Functions

func BuildBasePredictorFromInferenceService

func BuildBasePredictorFromInferenceService(isvc *v1beta1.InferenceService) (*v1alpha1.Predictor, error)

func ResolveSource

func ResolveSource(nn types.NamespacedName, defaultSource string) (types.NamespacedName, string)

Types

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type EventType

type EventType int

type InferenceServiceRegistry

type InferenceServiceRegistry struct {
	Client client.Client
}

func (InferenceServiceRegistry) Find

func (isvcr InferenceServiceRegistry) Find(ctx context.Context, namespace string,
	predicate func(*v1alpha1.Predictor) bool) (bool, error)

func (InferenceServiceRegistry) Get

func (InferenceServiceRegistry) GetSourceName

func (isvcr InferenceServiceRegistry) GetSourceName() string

func (InferenceServiceRegistry) UpdateStatus

func (isvcr InferenceServiceRegistry) UpdateStatus(ctx context.Context, predictor *v1alpha1.Predictor) (bool, error)

type PredictorCRRegistry

type PredictorCRRegistry struct {
	Client client.Client
}

func (PredictorCRRegistry) Find

func (pr PredictorCRRegistry) Find(ctx context.Context, namespace string,
	predicate func(*api.Predictor) bool) (bool, error)

func (PredictorCRRegistry) Get

func (PredictorCRRegistry) GetSourceName

func (pr PredictorCRRegistry) GetSourceName() string

func (PredictorCRRegistry) UpdateStatus

func (pr PredictorCRRegistry) UpdateStatus(ctx context.Context, predictor *api.Predictor) (bool, error)

UpdateStatus returns true if update was successful

type PredictorEvent

type PredictorEvent types.NamespacedName

type PredictorEventChan

type PredictorEventChan chan PredictorEvent

func (*PredictorEventChan) Event

func (pec *PredictorEventChan) Event(name string, namespace string)

type PredictorEventStream

type PredictorEventStream chan PredictorStreamEvent

type PredictorRegistry

type PredictorRegistry interface {
	// Get should retrieve the Predictor from a local cache that's synchronized via a watch
	Get(ctx context.Context, name types.NamespacedName) (*api.Predictor, error)

	// Find is temporary until runtime deployment scaling logic is refactored
	Find(ctx context.Context, namespace string, predicate func(*api.Predictor) bool) (bool, error)

	UpdateStatus(ctx context.Context, predictor *api.Predictor) (bool, error)

	GetSourceName() string
}

type PredictorSource

type PredictorSource interface {
	// StartWatch should not return until PredictorRegistry is fully populated
	StartWatch(ctx context.Context) (PredictorRegistry, PredictorEventChan, error)
	// GetSourceId return short, fixed and unique identifier for this source
	GetSourceId() string
}

PredictorSource provides a registry of Predictors along with a channel of update events corresponding to the Predictors. An event should be produced for every Predictor upon starting, and subsequently each time any Predictor is added, has its Spec modified, or is deleted.

func NewPredictorStreamSource

func NewPredictorStreamSource(id string, name string,
	events PredictorEventStream, updater PredictorStatusUpdater) PredictorSource

NewPredictorStreamSource returns a new PredictorSource based on a persistent event stream

func NewWatchPredictorSource

func NewWatchPredictorSource(id string, name string, watcher PredictorWatcher) PredictorSource

NewWatchPredictorSource returns a new PredictorSource based on a refresh-and-watch PredictorWatcher implementation

type PredictorStatusUpdater

type PredictorStatusUpdater interface {
	// UpdateStatus updates the given Predictor's status conditional on its resource version.
	// The returned boolean reflects whether the conditional update was successful; in both
	// cases the returned Predictor will reflect the latest version from the source *including
	// its updated resource version*.
	// In the case that the Predictor is not found, (nil, rv, false, nil) will be returned, where
	// rv is the current resource version at which the Predictor was observed to not be found.
	UpdateStatus(ctx context.Context, p *api.Predictor) (newP *api.Predictor, resourceVersion string, ok bool, err error)
}

type PredictorStreamEvent

type PredictorStreamEvent struct {
	EventType EventType
	Predictor *api.Predictor
}

Both UPDATE and DELETE events are expected to have a Predictor containing the corresponding resourceVersion

type PredictorWatcher

type PredictorWatcher interface {
	// UpdateStatus updates the given Predictor's status conditional on its resource version.
	// The returned boolean reflects whether the conditional update was successful; in both
	// cases the returned Predictor will reflect the latest version from the source *including
	// its updated resource version*.
	// In the case that the Predictor is not found, (nil, rv, false, nil) will be returned, where
	// rv is the current resource version at which the Predictor was observed to not be found.
	UpdateStatus(ctx context.Context, p *api.Predictor) (newP *api.Predictor, resourceVersion string, ok bool, err error)

	// Refresh returns a complete list of Predictors at the current point in time as of the
	// ResourceVersion contained in the returned PredictorList.
	// The limit arg may be used to request a limit, and the from arg can be used to request
	// a continuation list from a previously returned trucated list (the returned lists'
	// ResourceVersions will match in this case).
	Refresh(ctx context.Context, limit int, from string) (api.PredictorList, error)

	// Watch for predictor events starting from the specified resourceVersion. A returned error
	// of ERR_TOO_OLD indicates that the requested resourceVersion is too old. In this case a refresh/resync
	// is typically performed.
	Watch(ctx context.Context, resourceVersion string) (PredictorEventStream, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL