Documentation ¶
Overview ¶
Package metascheduler defines APIs for interacting with the DeepSquare Grid.
Package metascheduler providers implementations for interacting with the smart-contract.
Index ¶
- Constants
- Variables
- func CheckAffinities(affinities []types.Affinity, labels []metaschedulerabi.Label) bool
- func CheckReceiptError(ctx context.Context, client ethereum.GasEstimator, tx *types.Transaction, ...) error
- func CompareValues(op, valueA, valueB string) bool
- func CreditToDuration(prices metaschedulerabi.ProviderPrices, ...) (*big.Int, error)
- func DurationToCredit(prices metaschedulerabi.ProviderPrices, ...) *big.Int
- func IsPanicError(value byte) bool
- func JobIDFromHex(jobID string) [32]byte
- func JobIDToHex(jobID [32]byte) string
- func ParseArrayLengthMismatch(inputs []interface{}) error
- func ParseDoubleEndedQueueError(name string, inputs []interface{}) error
- func ParseError(name string, inputs []interface{}) error
- func ParseInvalidNodesCount(inputs []interface{}) error
- func ParseInvalidTotalCpus(inputs []interface{}) error
- func ParseInvalidTotalMem(inputs []interface{}) error
- func ParseNoJob(inputs []interface{}) error
- func WrapError(originalErr error) (newErr error)
- type AllowanceManager
- func (c *AllowanceManager) ClearAllowance(ctx context.Context) error
- func (c *AllowanceManager) GetAllowance(ctx context.Context) (*big.Int, error)
- func (c *AllowanceManager) ReduceToAllowance(ctx context.Context, approvals <-chan types.Approval) (<-chan *big.Int, error)
- func (c *AllowanceManager) SetAllowance(ctx context.Context, amount *big.Int) error
- type AlreadyDone
- type ArrayLengthMismatch
- type Backend
- type Banned
- type CreditManager
- func (c *CreditManager) Balance(ctx context.Context) (*big.Int, error)
- func (c *CreditManager) BalanceOf(ctx context.Context, address common.Address) (*big.Int, error)
- func (c *CreditManager) ReduceToBalance(ctx context.Context, transfers <-chan types.Transfer) (<-chan *big.Int, error)
- func (c *CreditManager) Transfer(ctx context.Context, to common.Address, amount *big.Int) error
- type CustomerMetaSchedulerProviderOnly
- type CustomerOnly
- type DoubleEndedQueueEmpty
- type DoubleEndedQueueOutOfBounds
- type EthereumBackend
- type EventSubscriber
- type InsufficientFunds
- type InvalidJob
- type InvalidJobDefinition
- type InvalidNodesCount
- type InvalidTotalCpus
- type InvalidTotalMem
- type InvalidTransition
- type JobFetcher
- type JobHotStatusOnly
- type JobProviderOnly
- type JobScheduler
- func (c *JobScheduler) CancelJob(ctx context.Context, id [32]byte) error
- func (c *JobScheduler) PanicJob(ctx context.Context, id [32]byte, reason string) error
- func (c *JobScheduler) SubmitJob(ctx context.Context, j *sbatch.Job, lockedAmount *big.Int, jobName [32]byte, ...) ([32]byte, error)
- func (c *JobScheduler) TopUpJob(ctx context.Context, id [32]byte, amount *big.Int) error
- type JobStatus
- type MetaScheduledScheduledStatusOnly
- type NewJobRequestDisabled
- type NoJob
- type NoProvider
- type NoSpendingAuthority
- type Oracle
- type OracleOptions
- type PanicError
- type ProviderManager
- func (c *ProviderManager) ApproveProvider(ctx context.Context, provider common.Address) error
- func (c *ProviderManager) GetProvider(ctx context.Context, address common.Address, ...) (detail provider.Detail, err error)
- func (c *ProviderManager) GetProviders(ctx context.Context, opts ...provider.GetProviderOption) (providers []provider.Detail, err error)
- func (c *ProviderManager) RemoveProvider(ctx context.Context, provider common.Address) error
- type ProviderNotJoined
- type RPCClientSet
- type RemainingTimeAboveLimit
- type RunningColdStatusOnly
- type RunningJobsByProviderFetcher
- type RunningScheduledStatusOnly
- type SameStatusError
- type WaitingApprovalOnly
Constants ¶
const DefaultOracleURL = "https://meta-scheduler.deepsquare.run"
DefaultOracleURL is the default oracle URL.
Variables ¶
var ErrDivByZero = errors.New("division by zero")
ErrDivByZero is the error returned when a division by zero happens.
var ( // ErrNewRequestJobNotFound happens when submitting a job, but the job is not found. // // This would typically be used for panicking. ErrNewRequestJobNotFound = errors.New("new request job event not found") )
Functions ¶
func CheckAffinities ¶ added in v1.5.0
func CheckAffinities( affinities []types.Affinity, labels []metaschedulerabi.Label, ) bool
CheckAffinities checks if the given labels satisfy the given affinities.
func CheckReceiptError ¶ added in v1.5.4
func CompareValues ¶ added in v1.5.0
CompareValues compares two values using the given operator.
func CreditToDuration ¶
func CreditToDuration( prices metaschedulerabi.ProviderPrices, definition metaschedulerabi.JobDefinition, creditsWei *big.Int, ) (*big.Int, error)
CreditToDuration converts credits to a job duration based on pricing and resources allocation.
func DurationToCredit ¶
func DurationToCredit( prices metaschedulerabi.ProviderPrices, definition metaschedulerabi.JobDefinition, durationMinutes *big.Int, ) *big.Int
DurationToCredit converts a job duration to credits based on pricing and resources allocation.
func IsPanicError ¶
IsPanicError checks if the byte of an error data is a panic error code.
func JobIDFromHex ¶ added in v1.2.2
JobIDFromHex converts a 32 bytes hexstring to a jobID
func JobIDToHex ¶ added in v1.2.2
JobIDToHex converts a jobID to an 32 bytes hexstring
func ParseArrayLengthMismatch ¶
func ParseArrayLengthMismatch(inputs []interface{}) error
func ParseError ¶
func ParseInvalidNodesCount ¶
func ParseInvalidNodesCount(inputs []interface{}) error
func ParseInvalidTotalCpus ¶
func ParseInvalidTotalCpus(inputs []interface{}) error
func ParseInvalidTotalMem ¶
func ParseInvalidTotalMem(inputs []interface{}) error
func ParseNoJob ¶
func ParseNoJob(inputs []interface{}) error
Types ¶
type AllowanceManager ¶ added in v1.5.4
type AllowanceManager struct { *RPCClientSet *metaschedulerabi.IERC20 }
AllowanceManager is a manager for allowances.
func (*AllowanceManager) ClearAllowance ¶ added in v1.5.4
func (c *AllowanceManager) ClearAllowance(ctx context.Context) error
ClearAllowance clears the allowance for the metascheduler.
func (*AllowanceManager) GetAllowance ¶ added in v1.5.4
GetAllowance gets the allowance for the metascheduler.
func (*AllowanceManager) ReduceToAllowance ¶ added in v1.5.4
func (c *AllowanceManager) ReduceToAllowance( ctx context.Context, approvals <-chan types.Approval, ) (<-chan *big.Int, error)
ReduceToAllowance reduces the stream of allowance to the allowance.
func (*AllowanceManager) SetAllowance ¶ added in v1.5.4
SetAllowance sets the allowance for the metascheduler.
type AlreadyDone ¶
type AlreadyDone struct{}
func ParseAlreadyDone ¶
func ParseAlreadyDone(_ []interface{}) *AlreadyDone
func (*AlreadyDone) Error ¶
func (e *AlreadyDone) Error() string
type ArrayLengthMismatch ¶
type ArrayLengthMismatch struct{}
func (*ArrayLengthMismatch) Error ¶
func (e *ArrayLengthMismatch) Error() string
type Backend ¶
type Backend struct { MetaschedulerAddress common.Address // EthereumBackend is the Ethereum Client. EthereumBackend // ChainID of the blockchain. ChainID *big.Int // PrivateKey of the user. UserPrivateKey *ecdsa.PrivateKey }
Backend is a wrapper around the EthereumBackend used to interact with the Meta-Scheduler smart-contract.
type CreditManager ¶ added in v1.5.4
type CreditManager struct { *RPCClientSet *metaschedulerabi.IERC20 }
CreditManager is a manager for credits.
func (*CreditManager) BalanceOf ¶ added in v1.5.4
BalanceOf returns the balance of the given address.
func (*CreditManager) ReduceToBalance ¶ added in v1.5.4
func (c *CreditManager) ReduceToBalance( ctx context.Context, transfers <-chan types.Transfer, ) (<-chan *big.Int, error)
ReduceToBalance reduces the balance to the given value.
type CustomerMetaSchedulerProviderOnly ¶
type CustomerMetaSchedulerProviderOnly struct{}
func ParseCustomerMetaSchedulerProviderOnly ¶
func ParseCustomerMetaSchedulerProviderOnly( inputs []interface{}, ) *CustomerMetaSchedulerProviderOnly
func (*CustomerMetaSchedulerProviderOnly) Error ¶
func (e *CustomerMetaSchedulerProviderOnly) Error() string
type CustomerOnly ¶
func ParseCustomerOnly ¶
func ParseCustomerOnly(inputs []interface{}) *CustomerOnly
func (*CustomerOnly) Error ¶
func (e *CustomerOnly) Error() string
type DoubleEndedQueueEmpty ¶
type DoubleEndedQueueEmpty struct{}
func ParseDoubleEndedQueueEmpty ¶
func ParseDoubleEndedQueueEmpty(inputs []interface{}) *DoubleEndedQueueEmpty
func (*DoubleEndedQueueEmpty) Error ¶
func (e *DoubleEndedQueueEmpty) Error() string
type DoubleEndedQueueOutOfBounds ¶
type DoubleEndedQueueOutOfBounds struct{}
func ParseDoubleEndedQueueOutOfBounds ¶
func ParseDoubleEndedQueueOutOfBounds(inputs []interface{}) *DoubleEndedQueueOutOfBounds
func (*DoubleEndedQueueOutOfBounds) Error ¶
func (e *DoubleEndedQueueOutOfBounds) Error() string
type EthereumBackend ¶
type EthereumBackend interface { bind.ContractBackend bind.DeployBackend }
EthereumBackend combines bind.ContractBackend and bind.DeployBackend.
type EventSubscriber ¶ added in v1.5.4
type EventSubscriber struct {
// contains filtered or unexported fields
}
EventSubscriber is a subscriber for events.
func NewEventSubscriber ¶
func NewEventSubscriber( rpc Backend, ws Backend, ) *EventSubscriber
NewEventSubscriber creates an EventSubscriber used to watch events.
func (*EventSubscriber) SubscribeEvents ¶ added in v1.5.4
func (c *EventSubscriber) SubscribeEvents( ctx context.Context, opts ...event.SubscriptionOption, ) (ethereum.Subscription, error)
SubscribeEvents subscribes to events.
type InsufficientFunds ¶
func ParseInsufficientFunds ¶
func ParseInsufficientFunds(inputs []interface{}) *InsufficientFunds
func (*InsufficientFunds) Error ¶
func (e *InsufficientFunds) Error() string
type InvalidJob ¶
type InvalidJob struct{}
func ParseInvalidJob ¶
func ParseInvalidJob(inputs []interface{}) *InvalidJob
func (*InvalidJob) Error ¶
func (e *InvalidJob) Error() string
type InvalidJobDefinition ¶
type InvalidJobDefinition struct{}
func ParseInvalidJobDefinition ¶
func ParseInvalidJobDefinition( inputs []interface{}, ) *InvalidJobDefinition
func (*InvalidJobDefinition) Error ¶
func (e *InvalidJobDefinition) Error() string
type InvalidNodesCount ¶
type InvalidNodesCount struct{}
func (*InvalidNodesCount) Error ¶
func (e *InvalidNodesCount) Error() string
type InvalidTotalCpus ¶
type InvalidTotalCpus struct{}
func (*InvalidTotalCpus) Error ¶
func (e *InvalidTotalCpus) Error() string
type InvalidTotalMem ¶
type InvalidTotalMem struct{}
func (*InvalidTotalMem) Error ¶
func (e *InvalidTotalMem) Error() string
type InvalidTransition ¶
func ParseInvalidTransition ¶
func ParseInvalidTransition(inputs []interface{}) *InvalidTransition
func (*InvalidTransition) Error ¶
func (e *InvalidTransition) Error() string
type JobFetcher ¶ added in v1.5.4
type JobFetcher struct { *RPCClientSet *metaschedulerabi.IJobRepository }
JobFetcher is a fetcher for jobs.
func (*JobFetcher) Next ¶ added in v1.5.4
func (c *JobFetcher) Next(ctx context.Context, it job.LazyIterator) (ok bool)
Next returns the next job in the iterator.
type JobHotStatusOnly ¶
type JobHotStatusOnly struct {
Current JobStatus
}
func ParseJobHotStatusOnly ¶
func ParseJobHotStatusOnly(inputs []interface{}) *JobHotStatusOnly
func (*JobHotStatusOnly) Error ¶
func (e *JobHotStatusOnly) Error() string
type JobProviderOnly ¶
func ParseJobProviderOnly ¶
func ParseJobProviderOnly(inputs []interface{}) *JobProviderOnly
func (*JobProviderOnly) Error ¶
func (e *JobProviderOnly) Error() string
type JobScheduler ¶ added in v1.5.4
type JobScheduler struct { *RPCClientSet *metaschedulerabi.MetaScheduler *sbatch.Service }
JobScheduler is a scheduler for jobs.
func (*JobScheduler) CancelJob ¶ added in v1.5.4
func (c *JobScheduler) CancelJob(ctx context.Context, id [32]byte) error
CancelJob cancels the job with the given ID.
type JobStatus ¶
type JobStatus uint8
JobStatus is the job status stored in the smart-contract.
const ( // JobStatusPending means the job has been submitted, but the meta-scheduler // hasn't considered to schedule it yet. JobStatusPending JobStatus = 0 // JobStatusMetaScheduled means that the job has been scheduled to a cluster, but that cluster has not yet handled it. JobStatusMetaScheduled JobStatus = 1 // JobStatusScheduled means that the job has been scheduled to a worker node. JobStatusScheduled JobStatus = 2 // JobStatusRunning means that the job is running on a worker node. JobStatusRunning JobStatus = 3 // JobStatusCancelled means that the job has been cancelled by the user or admin. JobStatusCancelled JobStatus = 4 // JobStatusFinished means that the job has finished with success. JobStatusFinished JobStatus = 5 // JobStatusFailed means that the job has failed. JobStatusFailed JobStatus = 6 // JobStatusOutOfCredits means that the job has timed out. JobStatusOutOfCredits JobStatus = 7 // JobStatusPanicked means that the job has failed from an unexpected error. JobStatusPanicked JobStatus = 8 // JobStatusUnknown is a unknown state. JobStatusUnknown JobStatus = 255 )
type MetaScheduledScheduledStatusOnly ¶
type MetaScheduledScheduledStatusOnly struct {
Current JobStatus
}
func ParseMetaScheduledScheduledStatusOnly ¶
func ParseMetaScheduledScheduledStatusOnly( inputs []interface{}, ) *MetaScheduledScheduledStatusOnly
func (*MetaScheduledScheduledStatusOnly) Error ¶
func (e *MetaScheduledScheduledStatusOnly) Error() string
type NewJobRequestDisabled ¶
type NewJobRequestDisabled struct{}
func ParseNewJobRequestDisabled ¶
func ParseNewJobRequestDisabled(inputs []interface{}) *NewJobRequestDisabled
func (*NewJobRequestDisabled) Error ¶
func (e *NewJobRequestDisabled) Error() string
type NoProvider ¶
type NoProvider struct{}
func ParseNoProvider ¶
func ParseNoProvider(_ []interface{}) *NoProvider
func (*NoProvider) Error ¶
func (e *NoProvider) Error() string
type NoSpendingAuthority ¶
type NoSpendingAuthority struct{}
func ParseNoSpendingAuthority ¶
func ParseNoSpendingAuthority(inputs []interface{}) *NoSpendingAuthority
func (*NoSpendingAuthority) Error ¶
func (e *NoSpendingAuthority) Error() string
type Oracle ¶ added in v1.5.4
type Oracle struct {
// contains filtered or unexported fields
}
Oracle is a client for the meta-scheduler oracle.
func NewOracle ¶ added in v1.2.2
func NewOracle(url string, opts OracleOptions) *Oracle
NewOracle instanciates an Oracle.
type OracleOptions ¶ added in v1.2.2
OracleOptions are options for the oracle.
type PanicError ¶
type PanicError byte
PanicError is an native EVM error.
const ( // PanicErrorAssertionError happens when `assert` fails. PanicErrorAssertionError PanicError = 0x1 // PanicErrorArithmeticUnderOrOverflow happens when a number under or overflows. PanicErrorArithmeticUnderOrOverflow PanicError = 0x11 // PanicErrorDivisionByZero happens when a number is divided by a zero denominator. PanicErrorDivisionByZero PanicError = 0x12 // PanicErrorEnumConversionOutOfBounds happens when a number is out of bounds of an enum. PanicErrorEnumConversionOutOfBounds PanicError = 0x21 // PanicErrorIncorrectlyEncodedStorageByteArray happens when byte array is badly encoded. PanicErrorIncorrectlyEncodedStorageByteArray PanicError = 0x22 // PanicErrorPopOnEmptyArray happens when calling pop on an empty array. PanicErrorPopOnEmptyArray PanicError = 0x31 // PanicErrorArrayAccessOutOfBounds happens when calling an element from an index out of bounds of an array. PanicErrorArrayAccessOutOfBounds PanicError = 0x32 // PanicErrorTooMuchMemoryAllocated happens when there is too much memory allocated for the EVM. PanicErrorTooMuchMemoryAllocated PanicError = 0x41 // PanicErrorZeroInitializedVariable happens when a variable is not initialized and it is forbidden to use the zero value of that variable. PanicErrorZeroInitializedVariable PanicError = 0x51 )
func (PanicError) Error ¶
func (e PanicError) Error() string
type ProviderManager ¶ added in v1.5.4
type ProviderManager struct { *RPCClientSet *metaschedulerabi.IProviderManager }
ProviderManager is a manager for providers.
func (*ProviderManager) ApproveProvider ¶ added in v1.5.4
ApproveProvider approves a provider.
func (*ProviderManager) GetProvider ¶ added in v1.5.4
func (c *ProviderManager) GetProvider( ctx context.Context, address common.Address, opts ...provider.GetProviderOption, ) (detail provider.Detail, err error)
GetProvider returns a provider.
func (*ProviderManager) GetProviders ¶ added in v1.5.4
func (c *ProviderManager) GetProviders( ctx context.Context, opts ...provider.GetProviderOption, ) (providers []provider.Detail, err error)
GetProviders returns all providers.
func (*ProviderManager) RemoveProvider ¶ added in v1.5.4
RemoveProvider removes a provider.
type ProviderNotJoined ¶
type ProviderNotJoined struct{}
func ParseProviderNotJoined ¶
func ParseProviderNotJoined(inputs []interface{}) *ProviderNotJoined
func (*ProviderNotJoined) Error ¶
func (e *ProviderNotJoined) Error() string
type RPCClientSet ¶
type RPCClientSet struct {
*Backend
}
RPCClientSet is a set of clients that interact with DeepSquare.
func NewRPCClientSet ¶
func NewRPCClientSet(b Backend) *RPCClientSet
NewRPCClientSet creates an RPCClientSet.
func (*RPCClientSet) AllowanceManager ¶
func (c *RPCClientSet) AllowanceManager() *AllowanceManager
AllowanceManager creates an AllowanceManager.
func (*RPCClientSet) CreditManager ¶
func (c *RPCClientSet) CreditManager() *CreditManager
CreditManager creates a CreditManager.
func (*RPCClientSet) JobFetcher ¶
func (c *RPCClientSet) JobFetcher() *JobFetcher
JobFetcher creates a JobFetcher.
func (*RPCClientSet) JobScheduler ¶
func (c *RPCClientSet) JobScheduler( sbatch *sbatch.Service, ) *JobScheduler
JobScheduler creates a JobScheduler.
func (*RPCClientSet) ProviderManager ¶
func (c *RPCClientSet) ProviderManager() *ProviderManager
ProviderManager creates a ProviderManager.
type RemainingTimeAboveLimit ¶
func ParseRemainingTimeAboveLimit ¶
func ParseRemainingTimeAboveLimit( inputs []interface{}, ) *RemainingTimeAboveLimit
func (*RemainingTimeAboveLimit) Error ¶
func (e *RemainingTimeAboveLimit) Error() string
type RunningColdStatusOnly ¶
type RunningColdStatusOnly struct {
Current JobStatus
}
func ParseRunningColdStatusOnly ¶
func ParseRunningColdStatusOnly( inputs []interface{}, ) *RunningColdStatusOnly
func (*RunningColdStatusOnly) Error ¶
func (e *RunningColdStatusOnly) Error() string
type RunningJobsByProviderFetcher ¶ added in v1.5.4
type RunningJobsByProviderFetcher struct { job.MetaScheduledIDsFetcher job.Fetcher }
RunningJobsByProviderFetcher is a fetcher for jobs by provider.
func NewJobsByProviderFetcher ¶ added in v1.2.2
func NewJobsByProviderFetcher( oracle job.MetaScheduledIDsFetcher, fetcher job.Fetcher, ) *RunningJobsByProviderFetcher
NewJobsByProviderFetcher instanciates a JobsByProviderFetcher.
func (*RunningJobsByProviderFetcher) GetJobsByProvider ¶ added in v1.5.4
func (f *RunningJobsByProviderFetcher) GetJobsByProvider( ctx context.Context, providerAddress common.Address, ) ([]types.Job, error)
GetJobsByProvider returns all jobs for a given provider.
type RunningScheduledStatusOnly ¶
type RunningScheduledStatusOnly struct {
Current JobStatus
}
func ParseRunningScheduledStatusOnly ¶
func ParseRunningScheduledStatusOnly( inputs []interface{}, ) *RunningScheduledStatusOnly
func (*RunningScheduledStatusOnly) Error ¶
func (e *RunningScheduledStatusOnly) Error() string
type SameStatusError ¶
type SameStatusError struct{}
func ParseSameStatusError ¶
func ParseSameStatusError(inputs []interface{}) *SameStatusError
func (*SameStatusError) Error ¶
func (e *SameStatusError) Error() string
type WaitingApprovalOnly ¶
type WaitingApprovalOnly struct{}
func ParseWaitingApprovalOnly ¶
func ParseWaitingApprovalOnly(_ []interface{}) *WaitingApprovalOnly
func (*WaitingApprovalOnly) Error ¶
func (e *WaitingApprovalOnly) Error() string
Source Files ¶
- metascheduler_allowancemanager.go
- metascheduler_backend.go
- metascheduler_creditmanager.go
- metascheduler_doc.go
- metascheduler_error.go
- metascheduler_job_status.go
- metascheduler_jobfetcher.go
- metascheduler_jobs_by_provider_fetcher.go
- metascheduler_jobscheduler.go
- metascheduler_oracle.go
- metascheduler_providermanager.go
- metascheduler_rpc.go
- metascheduler_utils.go
- metascheduler_ws.go