bidstrategy

package
v1.5.0-dev14 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package bidstrategy is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatReason added in v1.1.5

func FormatReason(success bool, jobRequiresNodeTo string, fmtArgs ...any) string

Types

type BidStrategy

type BidStrategy interface {
	SemanticBidStrategy
	ResourceBidStrategy
}

func NewWaitingStrategy added in v0.3.26

func NewWaitingStrategy(underlying BidStrategy, waitOnBid, waitOnNoBid bool) BidStrategy

type BidStrategyRequest

type BidStrategyRequest struct {
	NodeID   string
	Job      models.Job
	Callback *url.URL
}

type BidStrategyResponse

type BidStrategyResponse struct {
	ShouldBid  bool   `json:"shouldBid"`
	ShouldWait bool   `json:"shouldWait"`
	Reason     string `json:"reason"`
}

func NewBidResponse added in v1.1.5

func NewBidResponse(success bool, jobRequiresNodeTo string, fmtArgs ...any) BidStrategyResponse

type CallbackBidStrategy added in v0.3.26

type CallbackBidStrategy struct {
	OnShouldBid             func(context.Context, BidStrategyRequest) (BidStrategyResponse, error)
	OnShouldBidBasedOnUsage func(context.Context, BidStrategyRequest, models.Resources) (BidStrategyResponse, error)
}

func NewFixedBidStrategy added in v0.3.25

func NewFixedBidStrategy(response, wait bool) *CallbackBidStrategy

FixedBidStrategy is a bid strategy that always returns the same response, which is useful for testing

func (*CallbackBidStrategy) ShouldBid added in v0.3.26

ShouldBid implements BidStrategy

func (*CallbackBidStrategy) ShouldBidBasedOnUsage added in v0.3.26

func (s *CallbackBidStrategy) ShouldBidBasedOnUsage(
	ctx context.Context,
	request BidStrategyRequest,
	resourceUsage models.Resources,
) (BidStrategyResponse, error)

ShouldBidBasedOnUsage implements BidStrategy

type ChainedBidStrategy

type ChainedBidStrategy struct {
	Semantics []SemanticBidStrategy
	Resources []ResourceBidStrategy
}

func NewChainedBidStrategy

func NewChainedBidStrategy(opts ...StrategyOpt) *ChainedBidStrategy

func (*ChainedBidStrategy) AddStrategy

func (c *ChainedBidStrategy) AddStrategy(opts ...StrategyOpt)

AddStrategy Add new strategy to the end of the chain NOTE: this is not thread safe.

func (*ChainedBidStrategy) ShouldBid

ShouldBid Iterate over all strategies, and return shouldBid if no error is thrown and none of the strategies return should not bid.

func (*ChainedBidStrategy) ShouldBidBasedOnUsage

func (c *ChainedBidStrategy) ShouldBidBasedOnUsage(
	ctx context.Context, request BidStrategyRequest, usage models.Resources) (BidStrategyResponse, error)

ShouldBidBasedOnUsage Iterate over all strategies, and return shouldBid if no error is thrown and none of the strategies return should not bid.

type JobSelectionPolicyProbeData

type JobSelectionPolicyProbeData struct {
	NodeID   string     `json:"NodeID"`
	Job      models.Job `json:"Job"`
	Callback *url.URL   `json:"Callback"`
}

the JSON data we send to http or exec probes TODO: can we just use the BidStrategyRequest struct?

func GetJobSelectionPolicyProbeData added in v1.0.0

func GetJobSelectionPolicyProbeData(request BidStrategyRequest) JobSelectionPolicyProbeData

Return JobSelectionPolicyProbeData for the given request

type MockBidStrategy added in v1.0.4

type MockBidStrategy struct {
	// contains filtered or unexported fields
}

MockBidStrategy is a mock of BidStrategy interface.

func NewMockBidStrategy added in v1.0.4

func NewMockBidStrategy(ctrl *gomock.Controller) *MockBidStrategy

NewMockBidStrategy creates a new mock instance.

func (*MockBidStrategy) EXPECT added in v1.0.4

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockBidStrategy) ShouldBid added in v1.0.4

ShouldBid mocks base method.

func (*MockBidStrategy) ShouldBidBasedOnUsage added in v1.0.4

func (m *MockBidStrategy) ShouldBidBasedOnUsage(ctx context.Context, request BidStrategyRequest, usage models.Resources) (BidStrategyResponse, error)

ShouldBidBasedOnUsage mocks base method.

type MockBidStrategyMockRecorder added in v1.0.4

type MockBidStrategyMockRecorder struct {
	// contains filtered or unexported fields
}

MockBidStrategyMockRecorder is the mock recorder for MockBidStrategy.

func (*MockBidStrategyMockRecorder) ShouldBid added in v1.0.4

func (mr *MockBidStrategyMockRecorder) ShouldBid(ctx, request any) *gomock.Call

ShouldBid indicates an expected call of ShouldBid.

func (*MockBidStrategyMockRecorder) ShouldBidBasedOnUsage added in v1.0.4

func (mr *MockBidStrategyMockRecorder) ShouldBidBasedOnUsage(ctx, request, usage any) *gomock.Call

ShouldBidBasedOnUsage indicates an expected call of ShouldBidBasedOnUsage.

type MockResourceBidStrategy added in v1.0.4

type MockResourceBidStrategy struct {
	// contains filtered or unexported fields
}

MockResourceBidStrategy is a mock of ResourceBidStrategy interface.

func NewMockResourceBidStrategy added in v1.0.4

func NewMockResourceBidStrategy(ctrl *gomock.Controller) *MockResourceBidStrategy

NewMockResourceBidStrategy creates a new mock instance.

func (*MockResourceBidStrategy) EXPECT added in v1.0.4

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockResourceBidStrategy) ShouldBidBasedOnUsage added in v1.0.4

func (m *MockResourceBidStrategy) ShouldBidBasedOnUsage(ctx context.Context, request BidStrategyRequest, usage models.Resources) (BidStrategyResponse, error)

ShouldBidBasedOnUsage mocks base method.

type MockResourceBidStrategyMockRecorder added in v1.0.4

type MockResourceBidStrategyMockRecorder struct {
	// contains filtered or unexported fields
}

MockResourceBidStrategyMockRecorder is the mock recorder for MockResourceBidStrategy.

func (*MockResourceBidStrategyMockRecorder) ShouldBidBasedOnUsage added in v1.0.4

func (mr *MockResourceBidStrategyMockRecorder) ShouldBidBasedOnUsage(ctx, request, usage any) *gomock.Call

ShouldBidBasedOnUsage indicates an expected call of ShouldBidBasedOnUsage.

type MockSemanticBidStrategy added in v1.0.4

type MockSemanticBidStrategy struct {
	// contains filtered or unexported fields
}

MockSemanticBidStrategy is a mock of SemanticBidStrategy interface.

func NewMockSemanticBidStrategy added in v1.0.4

func NewMockSemanticBidStrategy(ctrl *gomock.Controller) *MockSemanticBidStrategy

NewMockSemanticBidStrategy creates a new mock instance.

func (*MockSemanticBidStrategy) EXPECT added in v1.0.4

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSemanticBidStrategy) ShouldBid added in v1.0.4

ShouldBid mocks base method.

type MockSemanticBidStrategyMockRecorder added in v1.0.4

type MockSemanticBidStrategyMockRecorder struct {
	// contains filtered or unexported fields
}

MockSemanticBidStrategyMockRecorder is the mock recorder for MockSemanticBidStrategy.

func (*MockSemanticBidStrategyMockRecorder) ShouldBid added in v1.0.4

func (mr *MockSemanticBidStrategyMockRecorder) ShouldBid(ctx, request any) *gomock.Call

ShouldBid indicates an expected call of ShouldBid.

type ModerateJobRequest added in v0.3.26

type ModerateJobRequest struct {
	ClientID string
	JobID    string
	Response BidStrategyResponse
}

func (ModerateJobRequest) GetClientID added in v0.3.26

func (mjr ModerateJobRequest) GetClientID() string

type ResourceBidStrategy added in v1.0.0

type ResourceBidStrategy interface {
	ShouldBidBasedOnUsage(ctx context.Context, request BidStrategyRequest, usage models.Resources) (BidStrategyResponse, error)
}

type SemanticBidStrategy added in v1.0.0

type SemanticBidStrategy interface {
	ShouldBid(ctx context.Context, request BidStrategyRequest) (BidStrategyResponse, error)
}

type StrategyOpt added in v1.0.0

type StrategyOpt func(strategy *ChainedBidStrategy)

func WithResources added in v1.0.0

func WithResources(strategy ...ResourceBidStrategy) StrategyOpt

func WithSemantics added in v1.0.0

func WithSemantics(strategy ...SemanticBidStrategy) StrategyOpt

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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