Documentation
¶
Overview ¶
Copyright 2024 The Aibrix Team.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PodList ¶
type PodList interface {
// Len returns the number of pods in the list.
Len() int
// All returns a slice of all pods in the list.
All() []*v1.Pod
// Indexes returns a slice of indexes for querying pods by index.
Indexes() []string
// ListByIndex returns a slice of pods that match the given index.
ListByIndex(index string) []*v1.Pod
}
PodList is an interface for a list of pods and support for indexing and querying pods by index.
type Router ¶
type Router interface {
// Route selects a target pod from the provided list of pods.
// The input pods is guaranteed to be non-empty and contain only routable pods.
Route(ctx *RoutingContext, readyPodList PodList) (string, error)
}
Router defines the interface for routing logic to select target pods.
type RouterConstructor ¶
RouterConstructor defines a constructor for a router.
type RouterProvider ¶
type RouterProvider interface {
// GetRouter returns the router
GetRouter(ctx *RoutingContext) (Router, error)
}
RouterProvider provides a stateful way to get a router, allowing a struct to provide the router by strategy and model.
type RouterProviderFunc ¶
type RouterProviderFunc func(*RoutingContext) (Router, error)
RouterProviderFunc provides a stateless way to get a router
type RouterProviderRegistrationFunc ¶
type RouterProviderRegistrationFunc func() RouterProviderFunc
RouterProviderRegistrationFunc provides a way to register RouterProviderFunc
type RoutingAlgorithm ¶
type RoutingAlgorithm string
RoutingAlgorithm defines the routing algorithms
type RoutingContext ¶
type RoutingContext struct {
context.Context
Algorithm RoutingAlgorithm
Model string
Message string
RequestID string
User *string
// contains filtered or unexported fields
}
RoutingContext encapsulates the context information required for routing. It can be extended with more fields as needed in the future.
func NewRoutingContext ¶
func NewRoutingContext(ctx context.Context, algorithms RoutingAlgorithm, model string, message string, requestID string, user string) *RoutingContext
func (*RoutingContext) Delete ¶
func (r *RoutingContext) Delete()
func (*RoutingContext) HasRouted ¶
func (r *RoutingContext) HasRouted() bool
func (*RoutingContext) SetTargetPod ¶
func (r *RoutingContext) SetTargetPod(pod *v1.Pod)
func (*RoutingContext) TargetAddress ¶
func (r *RoutingContext) TargetAddress() string
func (*RoutingContext) TargetPod ¶
func (r *RoutingContext) TargetPod() *v1.Pod