bidstrategy

package
v0.3.29 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BidStrategy

type BidStrategy interface {
	ShouldBid(ctx context.Context, request BidStrategyRequest) (BidStrategyResponse, error)
	ShouldBidBasedOnUsage(ctx context.Context, request BidStrategyRequest, resourceUsage model.ResourceUsageData) (BidStrategyResponse, error)
}

func FromJobSelectionPolicy

func FromJobSelectionPolicy(jsp model.JobSelectionPolicy) BidStrategy

Create a BidStrategy that implements the passed JobSelectionPolicy.

func NewProviderInstalledArrayStrategy added in v0.3.24

func NewProviderInstalledArrayStrategy[K model.ProviderKey, P model.Providable](
	provider model.Provider[K, P],
	getter func(*model.Job) []K,
) BidStrategy

func NewProviderInstalledStrategy added in v0.3.24

func NewProviderInstalledStrategy[K model.ProviderKey, P model.Providable](
	provider model.Provider[K, P],
	getter func(*model.Job) K,
) BidStrategy

func NewWaitingStrategy added in v0.3.26

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

type BidStrategyRequest

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

type BidStrategyResponse

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

func NewShouldBidResponse

func NewShouldBidResponse() BidStrategyResponse

type CallbackBidStrategy added in v0.3.26

type CallbackBidStrategy struct {
	OnShouldBid             func(context.Context, BidStrategyRequest) (BidStrategyResponse, error)
	OnShouldBidBasedOnUsage func(context.Context, BidStrategyRequest, model.ResourceUsageData) (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 model.ResourceUsageData,
) (BidStrategyResponse, error)

ShouldBidBasedOnUsage implements BidStrategy

type ChainedBidStrategy

type ChainedBidStrategy struct {
	Strategies []BidStrategy
}

func NewChainedBidStrategy

func NewChainedBidStrategy(strategies ...BidStrategy) *ChainedBidStrategy

func (*ChainedBidStrategy) AddStrategy

func (c *ChainedBidStrategy) AddStrategy(strategy BidStrategy)

AddStrategy Add new strategy to the end of the chain

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 model.ResourceUsageData) (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 DistanceDelayStrategy

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

func (DistanceDelayStrategy) ShouldBid

func (DistanceDelayStrategy) ShouldBidBasedOnUsage

type DistanceDelayStrategyParams

type DistanceDelayStrategyParams struct {
	NetworkSize int
}

type ExternalCommandStrategy

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

func (*ExternalCommandStrategy) ShouldBid

func (*ExternalCommandStrategy) ShouldBidBasedOnUsage

type ExternalCommandStrategyParams

type ExternalCommandStrategyParams struct {
	Command string
}

type ExternalHTTPStrategy

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

func NewExternalHTTPStrategy

func NewExternalHTTPStrategy(params ExternalHTTPStrategyParams) *ExternalHTTPStrategy

func (*ExternalHTTPStrategy) ShouldBid

func (*ExternalHTTPStrategy) ShouldBidBasedOnUsage

type ExternalHTTPStrategyParams

type ExternalHTTPStrategyParams struct {
	URL string
}

type JobSelectionPolicyProbeData

type JobSelectionPolicyProbeData struct {
	NodeID   string     `json:"node_id"`
	JobID    string     `json:"job_id"`
	Spec     model.Spec `json:"spec"`
	Callback *url.URL   `json:"callback"`
}

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

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 NetworkingStrategy

type NetworkingStrategy struct {
	Accept bool
}

func NewNetworkingStrategy

func NewNetworkingStrategy(accept bool) *NetworkingStrategy

func (*NetworkingStrategy) ShouldBid

ShouldBid implements BidStrategy

func (*NetworkingStrategy) ShouldBidBasedOnUsage

func (s *NetworkingStrategy) ShouldBidBasedOnUsage(
	ctx context.Context,
	request BidStrategyRequest,
	resourceUsage model.ResourceUsageData,
) (BidStrategyResponse, error)

ShouldBidBasedOnUsage implements BidStrategy

type StatelessJobStrategy

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

func NewStatelessJobStrategy

func NewStatelessJobStrategy(params StatelessJobStrategyParams) *StatelessJobStrategy

func (*StatelessJobStrategy) ShouldBid

func (*StatelessJobStrategy) ShouldBidBasedOnUsage

type StatelessJobStrategyParams

type StatelessJobStrategyParams struct {
	RejectStatelessJobs bool
}

type TimeoutStrategy

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

func NewTimeoutStrategy

func NewTimeoutStrategy(params TimeoutStrategyParams) *TimeoutStrategy

func (*TimeoutStrategy) ShouldBid

type TimeoutStrategyParams

type TimeoutStrategyParams struct {
	MaxJobExecutionTimeout time.Duration
	MinJobExecutionTimeout time.Duration

	JobExecutionTimeoutClientIDBypassList []string
}

Jump to

Keyboard shortcuts

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