types

package
v1.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package types provides the main types of the library.

Index

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

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

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

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

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

type SubmitJobOptions struct {
	Uses       []Label
	Affinities []Affinity
}

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

Transfer is an event that happens when there is a ERC20 transaction.

Directories

Path Synopsis
abi

Jump to

Keyboard shortcuts

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