Documentation ¶
Overview ¶
Package types provides the main types of the library.
Index ¶
- type Affinity
- type AllowanceManager
- type Approval
- type CreditManager
- type EventSubscriber
- type Job
- type JobFetcher
- type JobLazyIterator
- type JobScheduler
- type JobTransition
- type Label
- type LogStream
- type Logger
- type NewJobRequest
- type ProviderDetail
- type ProviderManager
- type SubmitJobOption
- type SubmitJobOptions
- type SubscriptionOption
- type SubscriptionOptions
- type Transfer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Affinity ¶
type Affinity metaschedulerabi.Affinity
Affinity is a key-value object with an operator for filtering clusters.
type AllowanceManager ¶
type AllowanceManager interface { // Set the allowance for smart-contract interactions. SetAllowance(ctx context.Context, amount *big.Int) error // ClearAllowance is an alias to SetAllowance 0. ClearAllowance(ctx context.Context) error // Get the current allowance toward the contract. GetAllowance(ctx context.Context) (*big.Int, error) // ReduceToAllowance reduces a channel of approval into allowance. ReduceToAllowance( ctx context.Context, approvals <-chan Approval, ) (<-chan *big.Int, error) }
AllowanceManager set the allowed quantity of credit for smart-contract interactions.
type Approval ¶
type Approval *metaschedulerabi.IERC20Approval
Approval is an event that happens when an user sets a new allowance.
type CreditManager ¶
type CreditManager interface { // Balance fetches the current balance of credits. Balance(ctx context.Context) (*big.Int, error) // Balance fetches the current balance of credits. BalanceOf(ctx context.Context, address common.Address) (*big.Int, error) // Transfer tranfers credits from one address to another. Transfer(ctx context.Context, to common.Address, amount *big.Int) error // ReduceToBalance reduces a channel of transfers into balance. ReduceToBalance( ctx context.Context, transfers <-chan Transfer, ) (<-chan *big.Int, error) }
CreditManager handles the credits of the user.
type EventSubscriber ¶
type EventSubscriber interface { // Subscribe to metascheduler events. SubscribeEvents( ctx context.Context, opts ...SubscriptionOption, ) (ethereum.Subscription, error) }
EventSubscriber watches smart-contract events.
type Job ¶
type Job *metaschedulerabi.Job
Job is the object stored in the smart-contract for accounting.
type JobFetcher ¶
type JobFetcher interface { // Get a job. GetJob(ctx context.Context, id [32]byte) (Job, error) // Get a iterator of jobs. If there is no job, nil is returned. GetJobs(ctx context.Context) (JobLazyIterator, error) }
JobFetcher fetches jobs.
type JobLazyIterator ¶
type JobLazyIterator interface { // Fetches the next job. Next(ctx context.Context) (ok bool) // Fetches the previous job. Prev(ctx context.Context) (ok bool) // Get the current job. Current() Job // Get the current error. Error() error }
JobLazyIterator iterates on a lazy list of jobs.
When calling Next or Prev, a request will be sent to the data source.
type JobScheduler ¶
type JobScheduler interface { // Submit a batch script to the batch service and metascheduler. SubmitJob( ctx context.Context, job *sbatch.Job, lockedAmount *big.Int, jobName [32]byte, opts ...SubmitJobOption, ) ([32]byte, error) // Cancel a job. CancelJob(ctx context.Context, jobID [32]byte) error // TopUp a job. TopUpJob(ctx context.Context, jobID [32]byte, amount *big.Int) error // Panic a job. PanicJob(ctx context.Context, jobID [32]byte, reason string) error }
JobScheduler schedules and cancels jobs.
type JobTransition ¶
type JobTransition *metaschedulerabi.IJobRepositoryJobTransitionEvent
JobTransition is an event that happens when the status of a job changes.
type Label ¶
type Label metaschedulerabi.Label
Label is a key-value object used for filtering and annotating clusters.
type LogStream ¶
type LogStream loggerv1alpha1.LoggerAPI_ReadClient
LogStream is a readable stream of logs.
type Logger ¶
type Logger interface { // Watch the logs of a job WatchLogs(ctx context.Context, jobID [32]byte) (LogStream, error) }
Logger fetches the logs of a job.
type NewJobRequest ¶
type NewJobRequest *metaschedulerabi.MetaSchedulerNewJobRequestEvent
NewJobRequest is an event that happens when a user submit a job.
type ProviderDetail ¶
type ProviderDetail struct { metaschedulerabi.Provider IsWaitingForApproval bool IsValidForScheduling bool JobCount uint64 }
ProviderDetail contains all the specs and statuses of a Provider.
type ProviderManager ¶
type ProviderManager interface { Approve(ctx context.Context, provider common.Address) error Remove(ctx context.Context, provider common.Address) error GetProvider(ctx context.Context, address common.Address) (provider ProviderDetail, err error) GetProviders(ctx context.Context) (providers []ProviderDetail, err error) }
ProviderManager manages admin operation of providers
type SubmitJobOption ¶
type SubmitJobOption func(*SubmitJobOptions)
SubmitJobOption is used to apply default and optional parameters for submitting a job.
func WithAffinity ¶
func WithAffinity(affinities ...Affinity) SubmitJobOption
WithAffinity adds key-value filters with operators to the job, which filters the available clusters.
func WithUse ¶
func WithUse(labels ...Label) SubmitJobOption
WithUse adds strict key-value filters to the job, which filters the available clusters.
type SubmitJobOptions ¶
SubmitJobOptions is the object containing optional parameters for submitting a job.
type SubscriptionOption ¶
type SubscriptionOption func(*SubscriptionOptions)
SubscriptionOption applies default and optional parameters to the SubscribeEvents method.
func FilterApproval ¶
func FilterApproval(filtered chan<- Approval) SubscriptionOption
FilterApproval allows taking the Approval events from the subscription.
func FilterJobTransition ¶
func FilterJobTransition( filtered chan<- JobTransition, ) SubscriptionOption
FilterJobTransition allows taking the JobTransition events from the subscription.
func FilterNewJobRequest ¶
func FilterNewJobRequest( filtered chan<- NewJobRequest, ) SubscriptionOption
FilterNewJobRequest allows taking the NewJobRequest events from the subscription.
func FilterTransfer ¶
func FilterTransfer(filtered chan<- Transfer) SubscriptionOption
FilterTransfer allows taking the Transfer events from the subscription.
type SubscriptionOptions ¶
type SubscriptionOptions struct { NewJobRequestChan chan<- NewJobRequest JobTransitionChan chan<- JobTransition TransferChan chan<- Transfer ApprovalChan chan<- Approval }
SubscriptionOptions contains the channels used to pass events.
type Transfer ¶
type Transfer *metaschedulerabi.IERC20Transfer
Transfer is an event that happens when there is a ERC20 transaction.