mocks

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockFairnessPolicy

type MockFairnessPolicy struct {
	TypedNameV   plugin.TypedName
	NewStateFunc func(ctx context.Context) any
	PickFunc     func(ctx context.Context, flowGroup flowcontrol.PriorityBandAccessor) (flowcontrol.FlowQueueAccessor, error)
}

MockFairnessPolicy is a behavioral mock for the FairnessPolicy interface. Simple accessors are configured with public value fields (e.g., NameV). Complex methods with logic are configured with function fields (e.g., PickFunc).

func (*MockFairnessPolicy) NewState

func (m *MockFairnessPolicy) NewState(ctx context.Context) any

func (*MockFairnessPolicy) Pick

func (*MockFairnessPolicy) TypedName

func (m *MockFairnessPolicy) TypedName() plugin.TypedName

type MockFlowControlRequest

type MockFlowControlRequest struct {
	FlowKeyV             flowcontrol.FlowKey
	ByteSizeV            uint64
	InferenceRequestV    *scheduling.InferenceRequest
	ReceivedTimestampV   time.Time
	InitialEffectiveTTLV time.Duration
	IDV                  string
	MetadataV            map[string]any
	InferencePoolNameV   string
	ModelNameV           string
	TargetModelNameV     string
}

MockFlowControlRequest provides a mock implementation of the FlowControlRequest interface.

func NewMockFlowControlRequest

func NewMockFlowControlRequest(
	byteSize uint64,
	id string,
	key flowcontrol.FlowKey,
	opts ...MockRequestOption,
) *MockFlowControlRequest

NewMockFlowControlRequest creates a new MockFlowControlRequest instance with optional configuration.

func (*MockFlowControlRequest) ByteSize

func (m *MockFlowControlRequest) ByteSize() uint64

func (*MockFlowControlRequest) FlowKey

func (*MockFlowControlRequest) GetMetadata

func (m *MockFlowControlRequest) GetMetadata() map[string]any

func (*MockFlowControlRequest) ID

func (*MockFlowControlRequest) InferencePoolName

func (m *MockFlowControlRequest) InferencePoolName() string

func (*MockFlowControlRequest) InferenceRequest

func (m *MockFlowControlRequest) InferenceRequest() *scheduling.InferenceRequest

func (*MockFlowControlRequest) InitialEffectiveTTL

func (m *MockFlowControlRequest) InitialEffectiveTTL() time.Duration

func (*MockFlowControlRequest) ModelName

func (m *MockFlowControlRequest) ModelName() string

func (*MockFlowControlRequest) ReceivedTimestamp

func (m *MockFlowControlRequest) ReceivedTimestamp() time.Time

func (*MockFlowControlRequest) TargetModelName

func (m *MockFlowControlRequest) TargetModelName() string

type MockFlowQueueAccessor

type MockFlowQueueAccessor struct {
	NameV           string
	LenV            int
	ByteSizeV       uint64
	PeekHeadV       flowcontrol.QueueItemAccessor
	PeekTailV       flowcontrol.QueueItemAccessor
	FlowKeyV        flowcontrol.FlowKey
	OrderingPolicyV flowcontrol.OrderingPolicy
	CapabilitiesV   []flowcontrol.QueueCapability
}

MockFlowQueueAccessor is a simple stub mock for the FlowQueueAccessor interface. It is used for tests that require static, predictable return values from a queue accessor. For complex, stateful queue behavior, use the mock in ../../contracts/mocks.MockManagedQueue.

func (*MockFlowQueueAccessor) ByteSize

func (m *MockFlowQueueAccessor) ByteSize() uint64

func (*MockFlowQueueAccessor) Capabilities

func (*MockFlowQueueAccessor) FlowKey

func (*MockFlowQueueAccessor) Len

func (m *MockFlowQueueAccessor) Len() int

func (*MockFlowQueueAccessor) Name

func (m *MockFlowQueueAccessor) Name() string

func (*MockFlowQueueAccessor) OrderingPolicy

func (m *MockFlowQueueAccessor) OrderingPolicy() flowcontrol.OrderingPolicy

func (*MockFlowQueueAccessor) PeekHead

func (*MockFlowQueueAccessor) PeekTail

type MockOrderingPolicy

type MockOrderingPolicy struct {
	TypedNameV                 plugin.TypedName
	LessFunc                   func(a, b flowcontrol.QueueItemAccessor) bool
	RequiredQueueCapabilitiesV []flowcontrol.QueueCapability
}

MockOrderingPolicy is a behavioral mock for the OrderingPolicy interface. Simple accessors are configured with public value fields (e.g., TypedNameV). Complex methods with logic are configured with function fields (e.g., LessFunc).

func (*MockOrderingPolicy) Less

func (*MockOrderingPolicy) RequiredQueueCapabilities

func (m *MockOrderingPolicy) RequiredQueueCapabilities() []flowcontrol.QueueCapability

func (*MockOrderingPolicy) TypedName

func (m *MockOrderingPolicy) TypedName() plugin.TypedName

type MockPriorityBandAccessor

type MockPriorityBandAccessor struct {
	PriorityV         int
	PolicyStateV      any
	FlowKeysFunc      func() []flowcontrol.FlowKey
	QueueFunc         func(flowID string) flowcontrol.FlowQueueAccessor
	IterateQueuesFunc func(callback func(flow flowcontrol.FlowQueueAccessor) (keepIterating bool))
}

MockPriorityBandAccessor is a behavioral mock for the PriorityBandAccessor interface. Simple accessors are configured with public value fields (e.g., PriorityV). Complex methods with logic are configured with function fields (e.g., IterateQueuesFunc).

Convention: Fields suffixed with 'V' (e.g., PriorityV) are static Value return fields. This avoids collision with the interface method of the same name.

func (*MockPriorityBandAccessor) FlowKeys

func (*MockPriorityBandAccessor) IterateQueues

func (m *MockPriorityBandAccessor) IterateQueues(callback func(flow flowcontrol.FlowQueueAccessor) bool)

func (*MockPriorityBandAccessor) PolicyState

func (m *MockPriorityBandAccessor) PolicyState() any

func (*MockPriorityBandAccessor) Priority

func (m *MockPriorityBandAccessor) Priority() int

func (*MockPriorityBandAccessor) Queue

type MockQueueItemAccessor

type MockQueueItemAccessor struct {
	EnqueueTimeV     time.Time
	EffectiveTTLV    time.Duration
	OriginalRequestV flowcontrol.FlowControlRequest
	HandleV          flowcontrol.QueueItemHandle
}

MockQueueItemAccessor provides a mock implementation of the QueueItemAccessor interface.

func NewMockQueueItemAccessor

func NewMockQueueItemAccessor(
	byteSize uint64,
	reqID string,
	key flowcontrol.FlowKey,
	opts ...MockRequestOption,
) *MockQueueItemAccessor

NewMockQueueItemAccessor is a constructor for MockQueueItemAccessor that initializes the mock with a default MockFlowControlRequest and MockQueueItemHandle to prevent nil pointer dereferences in tests. It accepts MockRequestOptions to configure the underlying request.

func (*MockQueueItemAccessor) EffectiveTTL

func (m *MockQueueItemAccessor) EffectiveTTL() time.Duration

func (*MockQueueItemAccessor) EnqueueTime

func (m *MockQueueItemAccessor) EnqueueTime() time.Time

func (*MockQueueItemAccessor) Handle

func (*MockQueueItemAccessor) OriginalRequest

func (*MockQueueItemAccessor) SetHandle

func (m *MockQueueItemAccessor) SetHandle(handle flowcontrol.QueueItemHandle)

type MockQueueItemHandle

type MockQueueItemHandle struct {
	RawHandle      any
	IsInvalidatedV bool
}

MockQueueItemHandle provides a mock implementation of the QueueItemHandle interface.

func (*MockQueueItemHandle) Handle

func (m *MockQueueItemHandle) Handle() any

func (*MockQueueItemHandle) Invalidate

func (m *MockQueueItemHandle) Invalidate()

func (*MockQueueItemHandle) IsInvalidated

func (m *MockQueueItemHandle) IsInvalidated() bool

type MockRequestOption

type MockRequestOption func(*MockFlowControlRequest)

MockRequestOption is a functional option for configuring a MockFlowControlRequest.

type MockSaturationDetector

type MockSaturationDetector struct {
	TypedNameV   plugin.TypedName
	IsSaturatedV bool
	SaturationV  float64
}

MockSaturationDetector is a behavioral mock for the SaturationDetector interface.

func (*MockSaturationDetector) IsSaturated

func (m *MockSaturationDetector) IsSaturated() bool

func (*MockSaturationDetector) LastCheckTime

func (m *MockSaturationDetector) LastCheckTime() time.Time

func (*MockSaturationDetector) Saturation

func (m *MockSaturationDetector) Saturation(ctx context.Context, endpoints []datalayer.Endpoint) float64

func (*MockSaturationDetector) TypedName

func (m *MockSaturationDetector) TypedName() plugin.TypedName

Jump to

Keyboard shortcuts

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